UrbanPro
true

Learn Selenium from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Wait Handler implementation in WebDriver

Devendra V
18/04/2017 0 0

public void waitForElementPresence(By by) {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(ExpectedConditions.presenceOfElementLocated(by));
    }
    
    public void waitForElementPresence(WebElement elmt) {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(ExpectedConditions.visibilityOf(elmt));
    }

    public void waitForElementVisibility(By by) {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(ExpectedConditions.visibilityOfElementLocated(by));
    }

    public void waitForElementClickable(By by) {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(ExpectedConditions.elementToBeClickable(by));
    }
    
    public void waitForPageLoaded() {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(checkPageLoadStatus());
    }
    
    public void waitForElementNotVisible(By locator) {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));
    }
    
    public void waitTillTitleContains(String text) {
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(ExpectedConditions.titleContains(text));
    }
    
    public void waitForWindowPresence(Integer requiredWindowNo){
        Wait<WebDriver> wait = new WebDriverWait(driver, GLOBAL_TIME_OUT);
        wait.until(checkWindowPresence(requiredWindowNo.toString()));
    }
    
    public void sleep(int seconds){
        try {
            Thread.sleep(seconds*1000);
        } catch (InterruptedException e) {
            //Ignore the exception
        }
    }
    
    private Function<WebDriver, Boolean> checkPageLoadStatus() {
        return new Function<WebDriver, Boolean>() {
            public Boolean apply(WebDriver driver) {
                return ((JavascriptExecutor) driver).executeScript(
                        "return document.readyState").equals("complete");
            }
        };
    }

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Selenium Interview Question and answers
https://www.youtube.com/watch?v=YWdAh3gTc6c

Bhanu P.

0 0
0

Example of DependsOnMethod in TestNG
public class dependsonM { @Test public void login() { System.out.println("login"); } @Test (dependsOnMethods = {"login"}) public void email() { //Intentionally I am failing this testcase Assert.assertTrue(false);...
S

Sarthak C.

0 0
0

Explicit Wait in Web-Driver
The Explicit Wait is used to tell the Web Driver to wait for certain conditions (Expected Conditions) The explicit wait is an intelligent kind of wait and applied on a particular element Explicit wait...

Selenium WebDriver 3.0, Test NG and JAVA.
Hello, Selenium WebDriver 3.0 with GeckoDriver is the latest upgrade of Selenium. To execute automation test scripts in Mozilla browser we need to install GeckoDriver seperately and the scripts should...

Priority in TestNG
public class Priority { @Test (priority=1)public void login() {System.out.println("login");} @Testpublic void email1() {System.out.println("email1");} @Test (priority=-2)public void email2() {System.out.println("email2");} //I...
S

Sarthak C.

0 0
0
X

Looking for Selenium Classes?

The best tutors for Selenium Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Selenium with the Best Tutors

The best Tutors for Selenium Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more