python - 等到元素不出现 - Selenium

标签 python selenium selenium-webdriver wait

我试图点击按钮,然后等待页面加载。问题是我不知道如何告诉驱动程序等待,因为它必须在页面加载后搜索一些元素。

我认为我应该使用这样的东西:

wait.until(EC.invisibility_of_element_located...

但不知道如何让它发挥作用。

这是一段在页面加载后可见的 HTML。

<h1 class="special ng-binding">
   Rezervácia letu
   <strong class="js_log_fl_res ng-binding">Bratislava</strong> <span class="date js_log_fl_res ng-binding">14.07.2015</span> <strong class="js_log_fl_res ng-binding">Madrid</strong>
   <!-- ngIf: computed.second && computed.first.toCode === computed.second.fromCode --><span ng-if="computed.second &amp;&amp; computed.first.toCode === computed.second.fromCode" class="ng-scope">
   <span class="date js_log_fl_res ng-binding">23.07.2015</span>
   <strong class="js_log_fl_res ng-binding">Bratislava</strong>
   </span><!-- end ngIf: computed.second && computed.first.toCode === computed.second.fromCode -->
   <!-- ngIf: computed.second && computed.first.toCode !== computed.second.fromCode -->
</h1>

我想等到字符串“Rezervácia letu”没有出现在页面上。

你能给我一个提示吗?

最佳答案

invisibility_of_element_located() 有两个参数。您可以按如下方式使用它

WebDriverWait(driver, 10).until(
        EC.invisibility_of_element_located((By.CSS_SELECTOR, "h1.special.ng-binding"))

Here是如何使用它的示例。

关于python - 等到元素不出现 - Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31027005/

相关文章:

java - ChromeDriver 和 WebDriver 有什么区别?

亚马逊 linux/aws Lambda 上的 python selenium chromedriver

Python重新匹配空格和新行

python - Python 中的另一个 unicode 困惑

python将元组列表分成确定大小的间隔

java - testNG 并行执行不起作用

java - 在 selenium Web 驱动程序 firefox 中使用 javascriptexecutor 单击打印按钮时无法关闭打印对话框

python - 是否可以从多个同名元素中获取 get_attribute() ?

python - 使用 NumPy 和 matplotlib 绘制的图形上未显示某些点

python - 如何在 Selenium 中获取请求 header