I am trying mouse hover action on a visible element and then click on a hidden sub-menu item. move_to_element()
does not seem to be working with ChromeDriver. However, there are no exceptions on running the code, just the action isn't happening.
I have also tried sleep()
between actions and webDriverWait
which shows timeout on running the code.
I am using chrome 56.0 with python 2.7 and selenium 3.0.2.
Following is the HTML code
<a class="dropdown-toggle" href="about-us.html" data-toggle="dropdown" role="button" aria-expanded="false">
About
<i class="caret"></i>
</a>
<li>
<a href="about.html">Introduction</a>
</li>
Following is part of my test case
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
mainmenu = driver.find_element_by_xpath("path_to_about_element")
submenu =driver.find_element_by_xpath("path_to_introduction_element")
action=ActionChains(driver)
action.move_to_element(mainmenu)
action.move_to_element(submenu)
action.click().perform()
Thanks for your help guys. I finally figured out that
moveToElement()
doesn't work if physical cursor is inside the browser window. It is a known issue with ChromeDriver.https://bugs.chromium.org/p/chromedriver/issues/detail?id=605
Use the following code and let me know if still face the same issue :
Try below code and let me know the result:
This should perform mouse hovering over
mainmenu
element and wait untilsubmenu
element presence and clickability