我使用 WebDriver 等等,但我有一个问题。 页面上出现一个元素,该元素在 3 秒后消失。我想停止这次测试并在这次之后恢复测试(不 sleep )。我怎样才能做到这一点?我与 WebDriver 的关系:
WebDriverWait(self.driver, 15, poll_frequency=0.5, ignored_exceptions[ElementNotVisibleException, ElementNotSelectableException,NoSuchElementException, WebDriverException]).until(expected_conditions.element_to_be_clickable(FormPage.name))
最佳答案
您可以使用 invisibility_of_element_ located
预期条件来实现:
from selenium.webdriver.support import ui
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
ui.WebDriverWait(self.driver, 15).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "your_css_selector")))
PS:您可以使用任何其他定位器(ID、名称等)。
希望对你有帮助!
关于Python + Selenium : wait for disappearance of web element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54477459/