Python + Selenium : wait for disappearance of web element

标签 python selenium

我使用 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/

相关文章:

python - 为什么我在标签小部件中的文本周围出现难看的大括号? -Tkinter

python - Jupyterlab : Directory keeps redirecting to where jupyter_notebook_config. py 是

python - 如何折叠 pandas 中的行和列

java - 执行 PHPUnit_Selenium

python - 从数据提取中删除字母只留下数字Python

selenium - 在scrapy中推迟部分抓取

python - 我们可以根据特定单词过滤数据吗?

修复损坏的 xml 的 Pythonic 方法

python selenium 输入搜索查询然后等待

selenium - WebDriverError : no such session error using ChromeDriver Chrome through Jenkins and Selenium