selenium-键盘和鼠标事件
常见的键盘操作
from selenium.webdriver.common.keys import Keys
模拟enter键:send_keys(Keys.ENTER)
键盘F1~F12: send_keys(Keys.F1)
复制Ctrl+C:send_keys(Keys.CONTROL,'c')
粘贴Ctrl+V:send_keys(Keys.CONTROL,'v')
全选Ctrl+A:send_keys(Keys.CONTROL,'a')
剪切Ctrl+X:send_keys(Keys.CONTROL,'x')
制表键Tab:send_keys(Keys.TAB)
常见的鼠标操作
from selenium.webdriver.common.action_chains import ActionChains
鼠标悬停事件:
move_to_element(mouse)鼠标悬停
perform()
mouse = driver.find_element_by_link_text("设置")
ActionChains(driver).move_to_element(mouse).perform()