Get the App
SLTechnology News&Howtos  ›  Servers  › 

Mouse hover in selenium without js code

Shulou Source: shulou.com Published: 2022-06-03 07:54:22 11月17日 Update

A simple way to achieve mouse hover is difficult to achieve with the move_to_element () method in the Actions class that comes with selenium, because this method makes the mouse hover fleeting and can not achieve the effect of hovering. Or take the "Settings" in the upper right corner of Baidu's home page as an example, find the "search Settings" under the button, and click as follows:

From selenium import webdriver

Driver = webdriver.Firefox ()

Driver.get ('https://www.baidu.com/index.php?tn=06008006_2_pg')

Driver.implicitly_wait (2)

Set_element = driver.find_element_by_link_text ('Settings')

Driver.execute_script ("$(arguments [0]). Mouseover ()", set_element)

Search_set_ele = driver.find_element_by_link_text ('search Settings')

Search_set_ele.click ()

Tags: Mouse method search code flash button effect way or home page no Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia MariaDB Redmi Xiaomi