是的,WebDriverWaitexpected_conditions 模块都需要同时导入。

'WebDriverWait' 是一个等待模块,它可以在特定条件满足之前等待一段时间。

'expected_conditions' 是一个条件模块,它包含了一系列常用的等待条件,如 'presence_of_element_located'、'visibility_of_element_located' 等。

在使用 'WebDriverWait' 等待某个条件时,需要使用 'expected_conditions' 中的条件。因此,两个模块需要同时导入。

示例代码:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)

element = wait.until(EC.presence_of_element_located((By.ID, 'myElement')))
Selenium 中 WebDriverWait 和 expected_conditions 模块的导入

原文地址: https://www.cveoy.top/t/topic/lfkd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录