UI自动化测试代码的执行顺序就是:加载驱动->访问链接->页面操作
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
#加载驱动
driver = webdriver.Chrome()
#访问链接
driver.get("http://www.baidu.com")
#页面操作
inputElement = driver.find_element(By.ID,"kw")
inputElement.send_keys("测试")
searchElement = driver.find_element(By.ID,"su")
searchElement.click()
time.sleep(5)
#退出
driver.quit()
标签:webdriver,searchElement,python,selenium,driver,访问,pytest,import
From: https://www.cnblogs.com/oytao/p/17649960.html