Selenium Python 代码之打开网页自动填充内容并搜索
流程
inputElement.send_keys(Keys.BACK_SPACE )
inputElement.send_keys(Keys.BACK_SPACE )
inputElement = driver1.find_element_by_id("TextBox1")
inputElement.send_keys(w_str)
inputElement = driver1.find_element_by_id("TextBox1")
inputElement.send_keys(Keys.ENTER)
代码
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def search(ele,w_str):
inputElement=ele
inputElement = driver1.find_element_by_id("TextBox1")
inputElement.send_keys(Keys.BACK_SPACE )
inputElement = driver1.find_element_by_id("TextBox1")
inputElement.send_keys(w_str)
inputElement = driver1.find_element_by_id("TextBox1")
inputElement.send_keys(Keys.ENTER)
driver1= webdriver.Chrome()
url='http://www.guzicha.com'
driver1.get(url)
search(inputElement,'图')
更多精彩代码请关注我的专栏
网友评论