0 votes
1 view
in Devops and Agile by (25k points)

I want to do mouseover function over a drop-down menu. When we hover over the menu, it will show the new options. I tried to click the new options using the XPath. But cannot click the menus directly. So, as the manual way, I am trying to hover over the drop-down menu and then will click the new options.

Actions action = new Actions(webdriver);

WebElement we = webdriver.findElement(By.xpath("//html/body/div[13]/ul/li[4]/a"));


1 Answer

0 votes
by (63.3k points)

It's not really possible to perform a 'mouse hover' action, instead, you need to chain all of the actions that you want to achieve in one go. So move to the element that reveals the others, then during the same chain, move to the now revealed element and click on it.

When using Action Chains you have to remember to 'do it as a user would'.

Actions action = new Actions(webdriver); 

WebElement we = webdriver.findElement(By.xpath("html/body/div[13]/ul/li[4]/a")); 


Welcome to Intellipaat Community. Get your technical queries answered by top developers !