Wait until element not appears - Selenium

243 Views Asked by At

I'm trying to click on the button and then wait until page is loaded. The problem is that I can't figure out how to tell the driver to wait because it has to search for some elements after page is loaded.

I think that I should use something like this:

wait.until(EC.invisibility_of_element_located...

But don't know how to make it work.

Here is a piece of HTML which is visible after the page is loaded.

<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>

I would like to wait until the string 'Rezervácia letu' is not appearing on the page.

could you give me a hint?

1

There are 1 best solutions below

0
On

invisibility_of_element_located() take two parameters. You can use that as follows

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

Here is an example of how you can use that.