selenium 隱式等待報錯 value must be a non-negative integer


筆者運行代碼使用selenium的隱式等待時出現報錯:

 1 from selenium import webdriver # 從selenium導入webdriver
 2 import time
 3 driver = webdriver.Chrome()
 4 driver.get('https://www.baidu.com') # 獲取百度頁面
 5 driver.implicitly_wait(3)
 6 inputElement = driver.find_element_by_id('kw').send_keys(u"隱式等待") #獲取輸入框
 7 driver.implicitly_wait(3)
 8 searchButton = driver.find_element_by_id('su').click() #獲取搜索按鈕
 9 time.sleep(3)
10 driver.quit()

錯誤:

由於已經查驗過不是chrome.driver版本與chrome瀏覽器的版本不匹配的問題,所以筆者想到是不是selenium版本問題導致,筆者當前的selenium版本是selenium-3.5.0,卸載selenium-3.5.0,重新下載 selenium-3.141.0(pip install selenium==3.141.0)之后,運行程序,問題解決。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM