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

doWhile example in Java
public class doWhilePracticleEx { public void test() { } public static void main(String args) { String q1 = "Who is PM of India?"; String a1 = "Sonia Gandhi"; String a2 = "Rahul Gandhi"; String a3...
S

Sarthak C.

0 0
0

Overview on Auto IT and use in selenium webdriver
AutoIt v3 is a freeware BASIC-like scripting languages designed for automating the windows GUI and general scripting. It used a combination of simulated keystrokes, mouse movements and window/control manipulation...
S

How can everyone prepare to clear any Java interview?
Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview...

API Testing with SOAPUI training in pune
Training: API Testing With Soapui Expert Training Contents: Introduction to Webservices Learning Groovy Learning SOAP UI - free version READY API (SOAPUI PRO)- REST WEB SERVICES PARAMETERIZING TESTS
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