from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.common.keys import Keys #键盘按键操作 import time driver = webdriver.Chrome() try: driver.implicitly_wait(10) driver.get('http://www.jd.com/') time.sleep(5) #点击 清除 input = driver.find_element_by_id('key') input.send_keys(' Siege ' ) # Find Search button by class Search = driver.find_element_by_class_name ( ' the Button ' ) search.click () # click on the search button the time.sleep ( 3 ) INPUT2 = driver.find_element_by_id ( ' Key ' ) input2.clear () # clear input box the time.sleep ( . 1 ) input2.send_keys ( ' Murphy's Law ' ) input2.send_keys (Keys.ENTER) the time.sleep ( 10 ) the finally : driver.close ()