100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python上按右键_Python_Selenium之鼠标右键

python上按右键_Python_Selenium之鼠标右键

时间:2019-05-14 19:58:04

相关推荐

python上按右键_Python_Selenium之鼠标右键

Python_Selenium之鼠标右键

一、步骤:

(以百度为例)获取百度网址

找到需要右键的元素(定位),xpath表达式为“//*[@id=lg]/img”

然后,右键选择“在新标签页中打开图片”即可,在这里需要用到selenium中的ActionChains模块

二、ActionChains方法列表

click(on_element=None) ——单击鼠标左键

click_and_hold(on_element=None) ——点击鼠标左键,不松开

context_click(on_element=None) ——点击鼠标右键

double_click(on_element=None) ——双击鼠标左键

drag_and_drop(source, target) ——拖拽到某个元素然后松开

drag_and_drop_by_offset(source, xoffset, yoffset) ——拖拽到某个坐标然后松开

key_down(value, element=None) ——按下某个键盘上的键

key_up(value, element=None) ——松开某个键

move_by_offset(xoffset, yoffset) ——鼠标从当前位置移动到某个坐标

move_to_element(to_element) ——鼠标移动到某个元素

move_to_element_with_offset(to_element, xoffset, yoffset) ——移动到距某个元素(左上角坐标)多少距离的位置

perform() ——执行链中的所有动作

release(on_element=None

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。