Selenium Python 代码之打开网页自动填充内容并搜索
Selenium Python 代码之打开网页自动填充内容并搜索流程1、通过id找到文本框inputElement.send_keys(Keys.BACK_SPACE )2、发送删除键,清除一下之前文字
inputElement.send_keys(Keys.BACK_SPACE )3、发送需要查询对内容并送个回车
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,'图')
作者:LeepengX
链接:https://www.jianshu.com/p/1dd1a878dfb7
来源:简书
支持分享
页:
[1]