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 Web Driver commonly used method
Navigation Loading a web page in a current browser window driver.get("www.google.com") driver.navigate().to("www.google.com") driver.navigate().to("www.google.com") Move back & forward Driver.Navigate().Back() Driver.Navigate().Forward() Refresh...

Free selenium video tutorial
Hi All, Hope you are doing good. We uploaded few videos on Selenium components like IDE, RC and Webdriver on youtube channel you can watch them for free of cost. Kindly search with below link: ...
S

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

Is Automation The Software Testing Miracle Cure?
The technology community is a big fan of automation. From DevOps’ continuous delivery roots to enterprises’ automatic business processes, automation is a trademark of the business world and...

Why JAVA is Platform Independent?
Java is platform independent language because Java has a JVM {Java Virtual Machine} which converts a java code into a byte code which can run on any OS. That means, JVM is working as a sub-platform to...
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