python學習之鼠標事件&鍵盤事件


driver.maximize_window()   瀏覽器最大化

ActionChains類與輸入事件

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

2:ActionChains(driver):用於生產模擬用戶行為

3:perform():執行存儲行為;

 

#鼠標事件:

#context_click 右擊事件

#double_click雙擊事件

#drag_and_drop 拖動

#click_and_hold按下鼠標左鍵在一個元素上

#move_to_element(ele)鼠標停在一個元素上

ele = driver.find_element_by_link_text('企業直通班')

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

 

鍵盤事件:

from selenium.webdriver.common.keys import Keys

send_keys(Keys.BACK_SPACE) 退格鍵

send_keys(Keys.CONTRL,'a')全選

send_keys(Keys.CONTRL,'v')粘貼

send_keys(Keys.CONTRL,'c')復制

send_keys(Keys.CONTRL,'x')剪切

send_keys(keys.ENTER)回車

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM