selenium ActionChains

在元素定位中的层级定位中简单使用了ActionChains 类,下面进行详细介绍


class ActionChains(driver)

driver:The WebDriver instance which performs user actions.

Generate user actions. All actions are stored in the ActionChains object. Call perform() to fire stored actions.

 

1.– perform()

运行

Performs all stored actions.

2.– click(on_element=None)

左键单击element

Clicks an element.

on_element:The element to click. If None, clicks on current mouse position.

 3.– click_and_hold(on_element)

左键单击element后保持

Holds down the left mouse button on an element.

on_element:The element to mouse down. If None, clicks on current mouse position.

 4.– context_click(on_element)

右键单击element

Performs a context-click (right click) on an element.

on_element:The element to context-click. If None, clicks on current mouse position.

 5.– double_click(on_element)

左键双击element

Double-clicks an element.

on_element:The element to double-click. If None, clicks on current mouse position.

6.– drag_and_drop(source, target)

左键单击source element,保持并移动到target element的位置,释放左键

Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button.

source:The element to mouse down.

target: The element to mouse up.

 7.– key_down(key, element=None)

按键不放

Sends a key press only, without releasing it. Should only be used with modifier keys (Control, Alt andShift).

key:The modifier key to send. Values are defined in Keys class.

element:The element to send keys. If None, sends a key to current focused element.

8– key_up(key, element=None)

松开按键

Releases a modifier key.

key:The modifier key to send. Values are defined in Keys class.

element:The element to send keys. If None, sends a key to current focused element.

9 – move_by_offset(xoffset, yoffset)

将鼠标移动offset距离

Moving the mouse to an offset from current mouse position.

xoffset:X offset to move to.yoffset:Y offset to move to.

10. – move_to_element(to_element)

将鼠标移动到元素的中间

Moving the mouse to the middle of an element.

to_element: The element to move to.

11.– move_to_element_with_offset(to_element, xoffset, yoffset)

将鼠标移动到当前element的offset距离

Move the mouse by an offset of the specificed element. Offsets are relative to the top-left corner of the

element.

to_element: The element to move to.xoffset:X offset to move to.yoffset:Y offset to move to.

12.– release(on_element)

释放鼠标

Releasing a held mouse button.

on_element:The element to mouse up.

13.– send_keys(*keys_to_send)

向当前激活element输入keys

Sends keys to current focused element.

keys_to_send:The keys to send.

 – send_keys_to_element(self, element,*keys_to_send):

向element输入keys

Sends keys to an element.

element:The element to send keys.keys_to_send:The keys to send.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值