As you know, WebDriver is software web application regression testing tool and you will face many problems during your webdriver test case creation and execution. You must knows alternate solution if one not works for your software automation test scenario. For example, you have used IMPLICIT WAIT in your software automation test case but if it is not sufficient to handle your condition of waiting till element becomes invisible from page then you can use it's alternative way of using EXPLICIT WAIT in your test case.
In my PREVIOUS POST, I have describe use of visibilityOfElementLocated(By locator) method with explicit wait to wait till element becomes visible (not hidden) on software web application page. Now let we look at opposite side. If you wants webdriver to wait till element becomes invisible or hidden from page then we can use invisibilityOfElementLocated(By locator) method with wait condition.
Syntax for wait till element invisible from page is as bellow.
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//input[@id='text4']")));
In above syntax, you can change webdriver wait time from 15 to 20, 30 or more as per your requirement. Also you can use any OTHER ELEMENT LOCATING METHODS except By.xpath. Practical example of webdriver wait till element becomes invisible is as bellow.
@Test
public void test () throws InterruptedException, IOException
{
//Wait for element invisible
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//input[@id='text4']")));
System.out.print("Text box text4 is now invisible");
}
You can VIEW EXAMPLE OF "waitForElementNotPresent" IN SELENIUM IDE if you are using selenium IDE.
Hi what happens if the element we are looking for invisibility is not loaded in the page?
ReplyDeleteFor Ex. i am checking for text4 invisibility but that input box is not loaded/present in the page then it will wait till webdriver wait is completed or it will throw any error ????
will give an error, regarding element is not visible
DeleteAccording to above explanation it waits what time we specify it waits up to that time
ReplyDeleteshow,how the output comes with diagram.
ReplyDeletenot only coding...
super
ReplyDelete