selenium中的对输入框文本进行全选,复制,粘贴,剪切和删除

2021-08-02  本文已影响0人  DD丿

键盘全选操作

from selenium.webdriver.common.keys import Keys
driver.find_element_by_css_selector('#key-demo').send_keys(Keys.CONTROL,'a')
time.sleep(2)

键盘的复制操作

driver.find_element_by_css_selector('#key-demo').send_keys(Keys.CONTROL,'c')
time.sleep(2)

键盘的剪切操作

driver.find_element_by_css_selector('#key-demo').send_keys(Keys.CONTROL,'x')
time.sleep(2)

键盘的粘贴操作

driver.find_element_by_css_selector('#key-demo').send_keys(Keys.CONTROL,'v')
time.sleep(2)

键盘的删除操作

driver.find_element_by_css_selector('#key-demo').send_keys(Keys.CONTROL,'a')
driver.find_element_by_css_selector('#key-demo').send_keys(Keys.BACKSPACE)
time.sleep(2)

上一篇 下一篇

猜你喜欢

热点阅读