In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
The Keys class provides all the keystroke methods on the keyboard. Send_keys method is used to simulate keyboard input
The code is as follows:
From time import * from selenium import webdriver# introduces the Keys module from selenium.webdriver.common.keys import Keysdriver = webdriver.Chrome () url = "https://www.baidu.com"print('new access% s'% (url) driver.get (url) # input box input content driver.find_element_by_id ('kw'). Send_keys (' seleniumm') # delete a mdriver.find_element_by_id ('kw') .send_ with multiple inputs Keys (Keys.BACK_SPACE) # enter a space + 'tutorial' driver.find_element_by_id ('kw'). Send_keys (Keys.SPACE) driver.find_element_by_id (' kw'). Send_keys ('tutorial') sleep (3) # Select all input boxes driver.find_element_by_id ('kw'). Send_keys (Keys.CONTROL) 'a') # cut input box sleep (3) driver.find_element_by_id ('kw'). Send_keys (Keys.CONTROL,'x') # paste input box sleep (3) driver.find_element_by_id (' kw'). Send_keys (Keys.CONTROL,'v') # enter instead of clicksleep (3) driver.find_element_by_id ('kw'). Send_keys (Keys.ENTER) sleep (10) driver.quit ()
Common keyboard operations:
Send_keys (Keys.BACK_SPACE) delete key (BackSpace)
Send_keys (Keys.SPACE) Spacebar
Send_keys (Keys_TAB) Tab key
Send_keys (Keys_ESCAPE) Backoff key
Send_keys (Keys_ENTER) enter key
Send_keys (Keys.CONTRAL,'a') Select all (Ctrl+A)
Send_keys (Keys.CONTRAL,'c') replication (Ctrl+C)
Send_keys (Keys.CONTRAL,'x') cutting (Ctrl+X)
Send_keys (Keys.CONTRAL,'v') paste (Ctrl+V)
Send_keys (Keys.F1) keyboard F1
....
Send_keys (Keys.F12) keyboard F12
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.