Selenium鼠标键盘事件

鼠标事件

引入鼠标事件:from selenium.webdriver import ActionChains

perform() 方法

左键点击:ActionChains(driver).click().perform()

右键点击:ActionChains(driver).context_click().perform()

双击:ActionChains(driver).double_click().perform()

悬停:ActionChains(driver).move_to_element().perform()

悬停到指定偏移量:ActionChains(driver).move_to_element_with_offset().perfrom()

长按:ActionChains(driver).click_and_hold().perform()

拖动:ActionChains(driver).drag_and_drop()

拖动指定偏移量:ActionChains(driver).drag_and_drop_by_offset()

 

键盘事件

导入Keys模块: from selenium.webdriver.common.keys import keys

全选,复制,剪切,粘贴:inputElement.send_keys(Keys.CONTROL, "a/c/x/v")

 

posted @ 2021-09-01 16:46  睡不醒的冰淇凌  阅读(42)  评论(0)    收藏  举报