标签:click load key cto 常用 rom nload escape 鼠标
鼠标操作
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains driver=webdriver.Chrome(r"C:\Users\JChen46\Downloads\chromedriver_win32\chromedriver.exe") driver.implicitly_wait(10) driver.get("http://baidu.com") #右键操作 context_click(right_click) right_click=driver.find_element_by_id(‘kw‘) ActionChains(driver).context_click(right_click).perform() #perfo() 执行ActionChains中存储的所有操作,可以理解是对整个操作的提交 #悬停操作 move_to_element(above) above=driver.find_element_by_css_selector(‘#u1 > a.pf‘) ActionChains(driver).move_to_element(above).perform() #双击操作 double_click(right_click) ActionChains(driver).double_click(right_click).perform() #拖放操作 ele=driver.find_element_by_id(‘ele‘) target=driver.find_element_by_id(‘ele‘) ActionChains(driver).drag_and_drop(ele,target).perform() pass
键盘操作,大部分就是某个键的英文:
send_keys(Keys.BACK_SPACE) 删除键(backspace)
send_keys(Keys.SPACE) 空格键(space)
send_keys(Keys.TAB) Tab
send_keys(Keys.ESCAPE) Esc
send_keys(Keys.CONTROL,‘a‘) Ctrl+a,同时按键盘就这样写
send_keys(Keys.F5) F5,类似的键也都这样写
from selenium.webdriver.common.keys import Keys driver.find_element_by_id(‘kw‘).send_keys(Keys.F5)
标签:click load key cto 常用 rom nload escape 鼠标
原文地址:https://www.cnblogs.com/Jasper-changing/p/12529932.html