Example usage for org.openqa.selenium.support.ui ExpectedConditions urlToBe

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions urlToBe

Introduction

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

Prototype

public static ExpectedCondition<Boolean> urlToBe(final String url) 

Source Link

Document

An expectation for the URL of the current page to be a specific url.

Usage

From source file:com.fpt.datht.iap.AutoIAP.java

public static void getDataFromServer(String className) {
    int c = 0;/*from  w  w w  . j  av  a 2s  . c  o  m*/
    slots = new String[10];
    students = new LinkedList<>();
    new WebDriverWait(driver, 360).until(ExpectedConditions.titleIs("IAP"));
    driver.get("http://iap.fpt.edu.vn/activity");

    new WebDriverWait(driver, 360).until(ExpectedConditions.urlToBe("http://iap.fpt.edu.vn/activity/"));

    List<WebElement> els = driver.findElements(By.tagName("a"));
    System.out.println("Size a:" + els.size());
    for (WebElement e : els) {
        //  System.out.println(e.getText());
        if (e.getText().contains(className)) {

            slots[c] = e.getAttribute("href").replaceAll("http://iap.fpt.edu.vn/activity/index.php",
                    "http://iap.fpt.edu.vn/attendance/add.php");
            c++;
            count = c;
            // System.out.println(main);

        }
    }
    if (slots.length == 0)
        return;
    driver.get(slots[0]);

    try {
        new WebDriverWait(driver, 5)
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//input[@type='submit']")));

    } catch (TimeoutException ex) {
        driver.get(slots[0].replaceAll("add.php", "edit.php"));

    }
    //Auto Check Slot 1
    if (autoCheckSlot1) {
        List<WebElement> elsInput = driver.findElements(By.xpath(".//input[@type='radio' and @value='1' ]"));
        autoCheckAll(elsInput);
    }

    //Wating for submit
    new WebDriverWait(driver, 5000)
            .until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//font[@color='green']")));
    driver.get(slots[0].replaceAll("add.php", "edit.php"));
    //GET All checked
    List<WebElement> elsInputChecked = driver
            .findElements(By.xpath(".//input[@type='radio' and @value='1' and @checked]"));

    System.out.println("Size input checked:" + elsInputChecked.size());

    elsInputChecked.stream().map((e) -> {
        Student student = new Student();
        student.name = e.getAttribute("name");
        return student;
    }).forEach(students::add);

}

From source file:net.atf4j.webdriver.page.AbstractPageObject.java

License:Open Source License

/**
 * Wait until url is value.//w w w  .ja va  2 s.co  m
 *
 * @param url the url
 * @return true if within timeout, otherwise false.
 */
public Boolean waitUntilUrlIs(final String url) {
    return this.webDriverWait.until(ExpectedConditions.urlToBe(url));
}