【问题标题】:Wait until element not appears - Selenium等到元素不出现 - Selenium
【发布时间】:2015-06-24 12:46:53
【问题描述】:

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

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

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”没有出现在页面上。

你能给我一个提示吗?

【问题讨论】:

    标签: python selenium selenium-webdriver wait


    【解决方案1】:

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

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

    Here 是一个如何使用它的示例。

    【讨论】:

      猜你喜欢
      • 2011-10-23
      • 1970-01-01
      • 2015-08-29
      • 2018-01-12
      • 2020-03-26
      • 1970-01-01
      • 2014-05-03
      • 1970-01-01
      相关资源
      最近更新 更多