Web Automation Test-D3-Study Notes No. 4 (Detailed Explanation of Selenium-ActionChainsApi Interface)

ActionChains

In the process of UI automation testing, we often encounter the kind of scene where the elements appear only after the mouse is hovered, and then we have to simulate the mouse hovering to a certain position and do a series of coherent operations. Selenium gives We provide the ActionChains module.

introduction method

In fact, the core idea of ​​the implementation of the ActionChains module is that when you call the ActionChains method, it will not be executed immediately, but will store all operations in a List in order. When you call the perform() method, the queue The times in are executed sequentially. (Note: A ruler tool is recommended, MeasurerIt)

drag_and_drop

move_to_element

click

key_down 与 key_up

Sometimes when we need to simulate keyboard operation, we need to use the key operation in ActionChains. Two methods are provided, key_down and key_up, to simulate pressing a key on the keyboard, and releasing a key, the received The parameters are the Keys and elementObj of the key. Can be used in conjunction with send_keys (eg: select all, copy, cut, paste)

Keys is actually a keyboard event module provided by Selenium. When simulating keyboard events, you need to import the Keys module

import path

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326525759&siteId=291194637