标签:
The ActionChains implementation,
Bases: object
ActionChains are a way to automate low level interactions such as mouse movements, mouse button actions, key press, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop.
ActionChains can be used in a chain pattern:
menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav #submenu1")
ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform()
Or actions can be queued up one by one, then performed.:
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()
Either way, the actions are performed in the order they are called, one after another.
Clicks an element.
Args: |
|
---|
Holds down the left mouse button on an element.
Args: |
|
---|
Performs a context-click (right click) on an element.
Args: |
|
---|
Double-clicks an element.
Args: |
|
---|
Args: |
|
---|
Args: |
|
---|
Args: |
|
---|
Example, pressing ctrl+c:
ActionsChains(driver).key_down(Keys.CONTROL).send_keys(‘c‘).key_up(Keys.CONTROL).perform()
Releases a modifier key.
Args: |
|
---|
Example, pressing ctrl+c:
ActionsChains(driver).key_down(Keys.CONTROL).send_keys(‘c‘).key_up(Keys.CONTROL).perform()
Moving the mouse to an offset from current mouse position.
Args: |
|
---|
Moving the mouse to the middle of an element.
Args: |
|
---|
Args: |
|
---|
Performs all stored actions.
Releasing a held mouse button on an element.
Args: |
|
---|
Sends keys to current focused element.
Args: |
‘Keys’ class. |
---|
Sends keys to an element.
Args: |
‘Keys’ class. |
---|
WebDriver API——第3部分Action Chains
标签:
原文地址:http://www.cnblogs.com/hushaojun/p/4467474.html