Can anyone suggest how can I use Explicit wait in my automation test cases using Webdriver

0 votes
Can anyone suggest how can I use Explicit wait in my automation test cases using Webdriver?
Jul 23, 2019 in Selenium by Inder
276 views

1 answer to this question.

0 votes

Hi Inder, you can use Explicit wait in any automation test script in the following manner:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class ExplicitWaitDemo {
public static void main(String[] args) {

WebDriver driver = new ChromeDriver();
driver.get("http://www.edureka.co/");

driver.findElement(By.xpath("//button[text()='Sign Up']")).click();

// Create object of WebDriverWait class and it will wait max of 20 seconds.

WebDriverWait wait = new WebDriverWait(driver, 20);

// Here we will wait until element is not visible, if element is visible then it will return web element or else it will throw exception

WebElement element = wait
.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[text()='WebDriver']")));

boolean status = element.isDisplayed();

if (status) {

System.out.println("===== WebDriver is visible======");

} else {

System.out.println("===== WebDriver is not visible======");

}
}
}
answered Jul 23, 2019 by Abha

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Can anyone suggest how can I restore cookies in new browser window using Webdriver?

Hey Akshay, following code snippet would help ...READ MORE

answered Aug 14, 2019 in Selenium by Abha
• 28,080 points
476 views
0 votes
1 answer

How can I run test cases in parallel using Keyword Driven Framework?

One solution to try for executing test ...READ MORE

answered Jun 29, 2020 in Selenium by Alexander
893 views
0 votes
1 answer

Impilicit wait vs Explicit wait vs Fluent wait

Implicit wait: Your telling the WebDriver the ...READ MORE

answered Apr 14, 2018 in Selenium by king_kenny
• 3,710 points
2,659 views
0 votes
1 answer

Implicit wait & Explicit wait in selenium WebDriver

Implicit Wait:  While loading a web page in ...READ MORE

answered May 24, 2018 in Selenium by Meci Matt
• 9,460 points
765 views
0 votes
1 answer

Not able to use “explicit wait” in my code

To wait until the entire data has ...READ MORE

answered Mar 28, 2018 in Selenium by nsv999
• 5,500 points
495 views
0 votes
1 answer
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 28,080 points
1,108 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP