Not able to handle menu and submenu | Selenium Forum
M
Posted on 24/03/2016
Hi Ashish,

As per described by you in 16.2 video I am trying to write code for handling menu bar and sub menu on site which not having ui and li tags by using "Interface JavascriptExecutor" class and "executeScript" method. I think now syntax has been changed to use this function but not sure its not taking value in the format as you described in video. I am writing code for "ebay.in".In the page source of "ebay.in" there is no function "onmouseover" present so how can we call the javascript function using "Interface JavascriptExecutor" class and "executeScript" method from our selenium code . I have been stuck very badly while writing the code.Could you please help me on the same. I have attached screenshot for your reference.Here I want to hang over my mouse on Mobile and Accessories link.

Thanks in advance.

Code-
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
/*This program is for handling menu bar and their sub menu for the sites who not having ui and li tags
* In 70% of sites the navigation menu bar consist of ul and li tags and we can use there Actions class.
*But sites not having ui and li tags we need to use of JavascriptExecutor class
*/

public class JavaScript_Functions {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
//((JavascriptExecutor) driver).executeScript("alert('hello')", args);//JavascriptExecutor is a class in selenium which helps us to execute javascript
driver.get("http://www.ebay.in/");
driver.manage().window().maximize();
((JavascriptExecutor) driver).executeScript("p2057337.m1380.l6435", args);

}

}

M
Replied on 25/03/2016

what is this [color=#FF0000:33opjz3h]p2057337.m1380.l6435[/color:33opjz3h]