Python Reptile: Selenium mouse click secondary menu

Example selenium package ActionChains classes given below:

menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav #submenu1")

actions = ActionChains(driver)
actions.move_to_element(menu)
actions.click(hidden_submenu)
actions.perform()

The whole idea is:
1, respectively, first find the menu element and a second-level menu elements
2, New Action chain ActionChains
3, move the mouse to the previous menu, then will start after the mouse event, show hidden secondary menu
4, click on the second level menu
5, to perform the action chain
ps: If you click directly invisible elements will complain elements are not visible:element not visible

He published 189 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/NewBeeMu/article/details/105100840