我就很崩潰,寫了幾句代碼。如下,設定了一個隱式判斷30秒
然后 ind_elements_by_xpath ,這句如果取到值了,值會立刻回傳,如果沒有取到,就會等待30 秒在回傳。
這個30秒和我設定的隱式等待的值是一樣的什么情況,為什么會產生等待??
import time
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
driver = webdriver.Chrome(executable_path="chromedriver.exe") #指定chromedriver路徑
driver.implicitly_wait(30) #設定頁面超時時間
driver.get('https://www.baidu.com/')
print('開始驗證')
Array = driver.find_elements_by_xpath('//*[@id="su1"]') # 驗證加載測驗
if len(Array) == 0:
print('無驗證')
else:
print('有驗證')
uj5u.com熱心網友回復:
driver.implicitly_wait(30)屬于隱式等待,30S內找到元素就開始執行,30S后未找到就報錯。還有len(Array)這個好像是錯誤的寫法轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/29956.html
上一篇:Python 字符型替換問題
下一篇:純小白求助:把py檔案直接拖入cmd運行,提示syntax error unicode error unicodeescape code can't decod
