Importing classes: ActionChains - mouse operation chain forming a series of operations, the selenium ActionChains class to complete the simulation mouse
during the operation of the watch:
1, mouse operation, to put a list of
2, using the perform () execution list among all operating
mouse in the basic operation are:
click (click), double-click (double_click), right (context_click), suspension (move_to_element), drag (drag_and_drop), pause (pause)
and so on.
For a chestnut:
from selenium.webdriver.common.action_chains Import ActionChains from the Selenium Import webdriver Import Time # create objects Chrome Driver = webdriver.Chrome () # access Baidu driver.get ( " http://baidu.com " ) # find the elements ele = driver .find_element_by_xpath ( ' // div [@ ID = "U1"] // A [@ class = "PF"] ' ) # instantiated objects Action Chains # suspension to an element, 0.5 seconds dwell, perform operation performed ActionChains (driver ) .move_to_element (ELE) .pause (0.5 ) .perform () the time.sleep ( . 3) # Exit the browser driver.quit ()