看报错看了半天,说什么版本不对,又是要把chromedriver.exe放到哪哪哪,结果都不行
解决:
我看find_element函数中by参数默认是By.ID,就以为可以不用写,没写就报错了
最后就是把By.ID加上
测试代码
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
class TestWait:
def setup(self):
self.driver = webdriver.Chrome()
self.driver.get('https://www.baidu.com/')
self.driver.maximize_window()
self.driver.implicitly_wait(3)
def test_wait(self):
time.sleep(3)
self.driver.find_element(By.ID, 'kw').send_keys("pytest")
time.sleep(3)
self.driver.find_element(By.ID, 'su').click()
time.sleep(3)
结果