Selenium Python 代码之打开网页自动填充内容并搜索

Selenium Python 代码之打开网页自动填充内容并搜索

流程

    1. 通过id找到文本框
inputElement.send_keys(Keys.BACK_SPACE )
    1. 发送删除键,清除一下之前文字
inputElement.send_keys(Keys.BACK_SPACE )
    1. 发送需要查询对内容并送个回车
       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.

你可能感兴趣的:(Python源码大全)