Example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait.

Prototype

public WebDriverWait(WebDriver driver, Duration timeout) 

Source Link

Document

Wait will ignore instances of NotFoundException that are encountered (thrown) by default in the 'until' condition, and immediately propagate all others.

Usage

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtCancellationPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(By.className("cancellation-form")));
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOf(submitCancellationButton));
}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtReservationPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(By.className("reservation-form")));
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[name = 'name']")));
}

From source file:applicationdriverlayer.pageobjects.squash.booking.ErrorPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds).until(ExpectedConditions.titleIs("Grrr"));
}

From source file:applicationdriverlayer.pageobjects.squash.SquashBasePage.java

License:Apache License

private final void load(boolean alreadyLoading, Optional<WebElement> cachedWebElement,
        Optional<Boolean> expectChangedS3Page) {
    loadRecursionDepth++;//ww  w  .j  a va 2s . co  m
    if (!alreadyLoading) {
        Optional<String> url = getUrl();
        if (url.isPresent()) {
            // We have an URL and the page is not already loading, so let's initiate
            // page retrieval.
            driver.get(url.get());
        } else {
            fail("Cannot initiate a page get without an URL");
        }
    }

    if (cachedWebElement.isPresent()) {
        // We have a cached web element, so first wait for it to become stale
        new WebDriverWait(driver, explicitWaitTimeoutSeconds)
                .until(ExpectedConditions.stalenessOf(cachedWebElement.get()));
    }

    // Now wait for the page load to complete
    waitForLoadToComplete();

    // Give our derived class a chance to update its cached web element
    Optional<WebElement> updatedCachedWebElement = updateCachedWebElement();

    if (expectChangedS3Page.isPresent() && !isS3PageConsistent(expectChangedS3Page.get())) {
        // If page not in its eventually-consistent state, re-get the current url
        // N.B. current url may differ from result of getUrl() e.g. by having
        // different query params (such as the date in the case of bookings pages)
        if (loadRecursionDepth > 20) {
            fail("Load recursion depth limit exceeded in SquashBasePage");
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            System.out.println("Sleep before re-get-ing for S3 consistency was interrupted");
        }
        driver.get(driver.getCurrentUrl());
        load(true, updatedCachedWebElement, expectChangedS3Page);
    }

    loadRecursionDepth = 0;
}

From source file:at.tugraz.ist.cucumber.SeleniumStepdefs.java

License:Open Source License

private void jqueryWait() {
    Wait<WebDriver> wait = new WebDriverWait(driver(), 60);
    wait.until(jQueryReady());
}

From source file:automated_tests.InitialPopups.java

@Parameters("browser")
@BeforeClass//w  w  w  . j  a  va 2 s .c  om
public static void beforeTest(String browser) {
    //set browser driver
    if (browser.equalsIgnoreCase("firefox")) {
        System.setProperty("webdriver.gecko.driver", "C:\\webDrivers\\geckodriver.exe");
        driver = new FirefoxDriver();
        System.out.println("Set for browser " + browser);
    } else if (browser.equalsIgnoreCase("chrome")) {
        System.setProperty("webdriver.chrome.driver", "C:\\webDrivers\\chromedriver.exe");
        driver = new ChromeDriver();
        System.out.println("Set for browser " + browser);
    } else if (browser.equalsIgnoreCase("ie")) {
        System.setProperty("webdriver.ie.driver", "C:\\webDrivers\\IEDriverServer.exe");
        driver = new InternetExplorerDriver();
        System.out.println("Set for browser " + browser);
    }
    //Opera and IE only work on Windows?
    // System.setProperty("webdriver.opera.driver","/Users/catherineszeto/Documents/workspace/MPN/operadriver");
    // driver = new OperaDriver();
    // System.setProperty("webdriver.ie.driver","/Users/catherineszeto/Documents/workspace/MPN/IEDriverServer.exe");
    // driver = new InternetExplorerDriver();
    else {
        System.out.println("Driver not configured for browser " + browser);
    }

    wait = new WebDriverWait(driver, 20);
    //set base URL

}

From source file:backend.BackendLoginTest.java

@Test(description = "wfp backend setup", priority = 1)
public void frontendSetup() {
    driver.navigate().to("http://localhost:8082/workflow4people");
    WebDriverWait wait = new WebDriverWait(driver, 10);
    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("j_username")));
}

From source file:backend.MakeUserTest.java

@Test(description = "open user panel", priority = 1)
public void openUserPage() {
    driver.findElement(By.partialLinkText("Admin")).click();
    driver.findElement(By.partialLinkText("Users")).click();
    WebDriverWait wait = new WebDriverWait(driver, 10);
    WebElement elementButton = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
            "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]")));
}

From source file:backend.MakeUserTest.java

@Test(description = "create user", priority = 2, dependsOnMethods = { "openUserPage" })
public void makeUser() {
    WebDriverWait wait = new WebDriverWait(driver, 10);
    driver.findElement(By.xpath(/*from  w ww  . j  a va2  s .c o m*/
            "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]"))
            .click();
    WebElement elementUsername = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username")));
    textInput("username", "testUser123");
    textInput("userRealName", "test user");
    textInput("givenName", "test");
    textInput("familyName", "user");
    textInput("email", "testuser@gmail.com");
    driver.findElement(By.partialLinkText("Password")).click();
    WebElement elementPassword = wait
            .until(ExpectedConditions.visibilityOfElementLocated(By.id("newPassword")));
    textInput("newPassword", "test123");
    textInput("newPassword2", "test123");
    driver.findElement(By.xpath("//span[text()='OK']")).click();
    WebElement elementButton = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
            "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]")));
}

From source file:backend.MakeUserTest.java

@Test(description = "check if new user was succesfully added", priority = 3, dependsOnMethods = { "makeUser" })
public void validateNewUser() throws InterruptedException {
    WebDriverWait wait = new WebDriverWait(driver, 10);
    //sort descending(newest on top)
    WebElement table = driver.findElement(By.id("detailTable_person"));
    WebElement idCell = table.findElement(By.xpath("//th[text()='Id']"));
    idCell.click();/*  www.j av a 2s .  c o m*/
    Thread.sleep(500);

    //select first table entry
    List<WebElement> tableRows = table.findElements(By.tagName("tr"));
    String userId = tableRows.get(2).findElement(By.xpath("//td[1]")).getText();
    String nameCell = tableRows.get(2).findElement(By.xpath("//td[2]")).getText();

    //validate if first entry is the new user. delete user if true, fails test if false
    if (nameCell.equals("testUser123")) {
        WebElement delete = table.findElement(By.xpath("//span[@onclick=\"dialog.deleteDialog('" + userId
                + "','person',{ refresh : 'null'}, null)\"]"));
        delete.click();
        WebElement elementConfirm = wait
                .until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Delete']")));
        WebElement confirm = table.findElement(By.xpath("//span[text()='Delete']"));
        confirm.click();
        WebElement elementButton = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
                "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]")));
    } else {
        org.testng.Assert.fail("Test user was not succesfully created.");
    }
}