标签:rom end driver com drive www send 空格 port
一、鼠标操作
1.1鼠标的悬停操作,move_to_element
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains action=ActionChains(driver)#实例化鼠标类 action.move_to_element(“元素”).perform()#悬停操作,调用.perform()执行鼠标操作
1.2.鼠标的拖拽操作
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains
action=ActionChains(driver)#实例化鼠标类 action.drag_and_drop(“元素”).perform()#拖拽操作,调用.perform()执行鼠标操作
1.3.鼠标的右键操作
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains action=ActionChains(driver)#实例化鼠标类 action.context_click(“元素”).perform()#悬停操作,调用.perform()执行鼠标操作
1.4.鼠标的左键操作
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains action=ActionChains(driver)#实例化鼠标类 action.double_click(“元素”).perform()#悬停操作,调用.perform()执行鼠标操作
二、键盘操作
2.1鼠标的操作,先导入库,在send_keys()调用参数完成操作
from selenium import webdriver from selenium.webdriver.common.keys import Keys driver=webdriver.Chrome() driver.get("htttp://www.baidu.com") driver.find_element_by_id(‘kw‘).send_keys("测试") driver.find_element_by_id(‘kw‘).send_keys(Keys.ENTER)#通过鼠标的回车键来促发操作
2.2组合键
send_keys(Keys.CONTROL,‘a‘)#全选(ctrl+A)
send_keys(Keys.CONTROL,‘c‘)#复制(ctrl+C)
send_keys(Keys.CONTROL,‘x‘)#剪切(ctrl+X)
send_keys(Keys.CONTROL,‘v‘)#粘贴(ctrl+V)
2.3非组合键
回车键:send_keys(Keys.ENTER)
删除键:send_keys(Keys.BACK_SPACE)
空格键:send_keys(Keys.SPACE)
制表键:send_keys(Keys.TAB)
回退键:send_keys(Keys.ESCAPE)
刷新键:send_keys(Keys.F5)
标签:rom end driver com drive www send 空格 port
原文地址:https://www.cnblogs.com/hherbk/p/12700359.html