webdriver操作鍵盤

2022-05-14 08:53:38 字數 2133 閱讀 2138

from selenium.webdriver.common.keys import keys

null = '\ue000'

cancel = '\ue001' # ^break

help = '\ue002'

backspace = '\ue003'

back_space = backspace #刪除鍵

tab = '\ue004' #tab鍵

clear = '\ue005'

return = '\ue006'

enter = '\ue007' #回車鍵

shift = '\ue008' #shift鍵

left_shift = shift

control = '\ue009'

left_control = control #ctrl 鍵

alt = '\ue00a' #alt 鍵

left_alt = alt

pause = '\ue00b'

escape = '\ue00c' #ecs鍵

space = '\ue00d' #空格鍵

page_up = '\ue00e' #pgup 鍵

page_down = '\ue00f' #pgdwon 鍵

end = '\ue010' #end 鍵

home = '\ue011' #home 鍵

left = '\ue012' #左鍵

arrow_left = left

up = '\ue013' #上鍵

arrow_up = up

right = '\ue014'

arrow_right = right #右鍵

down = '\ue015' #下鍵

arrow_down = down

insert = '\ue016' #insert鍵

delete = '\ue017' #del鍵

semicolon = '\ue018' #';'鍵

equals = '\ue019' #'='鍵

#數字鍵盤

numpad0 = '\ue01a' # number pad keys

numpad1 = '\ue01b'

numpad2 = '\ue01c'

numpad3 = '\ue01d'

numpad4 = '\ue01e'

numpad5 = '\ue01f'

numpad6 = '\ue020'

numpad7 = '\ue021'

numpad8 = '\ue022'

numpad9 = '\ue023'

multiply = '\ue024' # '*' 鍵

add = '\ue025' # '+' 鍵

separator = '\ue026' #','鍵

subtract = '\ue027' # '-' 鍵

decimal = '\ue028' # '.'鍵

divide = '\ue029' #'/'鍵

f1 = '\ue031' # function keys

f2 = '\ue032'

f3 = '\ue033'

f4 = '\ue034'

f5 = '\ue035'

f6 = '\ue036'

f7 = '\ue037'

f8 = '\ue038'

f9 = '\ue039'

f10 = '\ue03a'

f11 = '\ue03b'

f12 = '\ue03c'

meta = '\ue03d'

command = '\ue03d'

組合

send_keys(keys.control,'a')   #全選(ctrl+a)

send_keys(keys.control,'c')   #複製(ctrl+c)

send_keys(keys.control,'x')   #剪下(ctrl+x)

send_keys(keys.control,'v')   #貼上(ctrl+v)

webdriver之滑鼠事件和鍵盤事件

在使用滑鼠操作方法需要匯入actionchains類 from selenium.webdriver.common.action chains import actionchains actionchains類提供了滑鼠操作的常用方法 perform 執行所有actionchains中儲存的行為 c...

WebDriver學習筆記 模擬鍵盤輸入

通過keys類和send keys 方法模擬鍵盤輸入 from selenium import webdriver 呼叫keys模組 from selenium.webdriver.common.keys import keys dri webdriver.chrome dri.get 在輸入框輸入...

python之webdriver頁面操作基礎 一

引入from selenium import webdriver import time 關閉谷歌瀏覽器提示欄 option webdriver.chromeoptions option.add argument disable infobars 開啟瀏覽器 driver webdriver.chr...