day03 元素交互操作
作者:互联网
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('围城') #通过class查找搜索按钮 search = driver.find_element_by_class_name('button') search.click() #点击搜索按钮 time.sleep(3) input2 = driver.find_element_by_id('key') input2.clear() #清空输入框 time.sleep(1) input2.send_keys('墨菲定律') input2.send_keys(Keys.ENTER) time.sleep(10) finally: driver.close()
标签:input2,day03,元素,driver,keys,sleep,time,import,交互 来源: https://www.cnblogs.com/zaccheo/p/11124295.html