Selenium Python 代碼之打開(kāi)網(wǎng)頁(yè)自動(dòng)填充內(nèi)容并搜索
流程
inputElement.send_keys(Keys.BACK_SPACE )
inputElement.send_keys(Keys.BACK_SPACE )
- 發(fā)送需要查詢對(duì)內(nèi)容并送個(gè)回車
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,'圖')
更多精彩代碼請(qǐng)關(guān)注我的專欄