Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - Wait until element is NOT visible

In the code below, I attempt to wait until an element is visible:

var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementIsVisible(By.Id("processing"))); 

Is it possible to tell driver to wait until that element is NOT visible?

like image 740
user2917239 Avatar asked Mar 25 '14 20:03

user2917239


People also ask

How wait until element is not present in Selenium?

This can be achieved with synchronization in Selenium. We shall add an explicit wait criteria where we shall stop or wait till the element no longer exists. Timeout exception is thrown once the explicit wait time has elapsed and the expected behavior of the element is still not available on the page.

How do you use wait until element is visible in Selenium?

Selenium: Waiting Until the Element Is Visiblevar wait = new WebDriverWait(driver, TimeSpan. FromSeconds(20)); As you can see, we give the WebDriverWait object two parameters: the driver itself and a TimeSpan object that represents the timeout for trying to locate the element.

How do I wait for an element to appear in Selenium Python?

To wait until element is present, visible and interactable with Python Selenium, we can use the wait. until method. Then we call wait.

How do I make Selenium wait 10 seconds?

We can make Selenium wait for 10 seconds. This can be done by using the Thread. sleep method. Here, the wait time (10 seconds) is passed as a parameter to the method.


2 Answers

Yes, it's possible with method invisibilityOfElementLocated

wait.until(ExpectedConditions.invisibilityOfElementLocated(locator)); 
like image 160
Alpha Avatar answered Sep 28 '22 04:09

Alpha


The following should wait until the element is no longer displayed i.e. not visible (or time out after 10 seconds)

var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10)); wait.Until(driver => !driver.FindElement(By.Id("processing")).Displayed); 

It will throw an exception if an element cannot be found with the id processing.

like image 21
Russ Cam Avatar answered Sep 28 '22 03:09

Russ Cam