selenium鍵盤事件和鼠標事件

模擬鼠標事件

1.from selenium.webdriver.common.action_chains import ActionChains

2:ActionChains(driver):用於生成模擬用戶行爲

3:perform():執行存儲行爲

表達式說明
context_click右擊事件
double_click雙擊事件
drag_and_drop拖動
move_to_element()鼠標停在一個元素上
click_and_hold按下鼠標左鍵在一個元素上

example: ActionChains(driver).move_to_element(ele).perform()

模擬鍵盤事件

send_keys()

from selenium.webdriver.common.keys import Keys

表達式說明
send_kyes(Kyes.BACK_SPACE)退格鍵
send_kyes(Kyes.CONTRL, 'a')全選
send_kyes(Kyes.CONTRL, 'v')粘貼
send_kyes(Kyes.CONTRL, 'c')複製
send_kyes(Kyes.CONTRL, 'x')剪切
send_kyes(Kyes.ENTER)回車


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章