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

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

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

Being a Tester.
Being a tester one should never ever work in an isolated environment. He should be aware of whole Product functionality and architecture.For starting you may proceed with - 1. Learn to login to the ip...

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

Xpath Cheatsheet
Xpath Descendant selectors h1 //h1 ? div p //div//p ? ul > li //ul/li ? ul > li > a //ul/li/a div > * //div/* :root
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