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

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

Introduction

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

Prototype

public static ExpectedCondition<WebElement> visibilityOf(final WebElement element) 

Source Link

Document

An expectation for checking that an element, known to be present on the DOM of a page, is visible.

Usage

From source file:com.hotwire.selenium.desktop.us.billing.car.impl.ccf.CcfDetailsFragment.java

License:Open Source License

private String[] getVendorAsArray(WebElement vendorRow) {
    new WebDriverWait(getWebDriver(), DEFAULT_WAIT).until(ExpectedConditions.visibilityOf(vendorRow));
    return new String[] { vendorRow.findElement(By.cssSelector("div.logo img")).getAttribute("alt"),
            vendorRow.findElement(By.cssSelector("div.price .perDay")).getText().replaceAll("[^0-9.]", ""),
            vendorRow.findElement(By.cssSelector("div.price .total")).getText().replaceAll("[^0-9.]", ""),
            vendorRow.findElement(By.cssSelector(
                    "div.price .perDay .amount .singleCurrency, div.price .perDay" + " .amount .multiCurrency"))
                    .getText().trim(), };
}

From source file:com.hotwire.selenium.desktop.us.partners.HotelHotelsPage.java

License:Open Source License

public HotelHotelsPage(WebDriver webdriver) {
    super(webdriver);
    WebDriverWait wait = new WebDriverWait(webdriver, 3);
    wait.until(ExpectedConditions.visibilityOf(changeSearch));
}

From source file:com.hotwire.selenium.desktop.us.partners.HotelKayakPage.java

License:Open Source License

public HotelKayakPage(WebDriver webdriver) {
    super(webdriver);
    WebDriverWait wait = new WebDriverWait(webdriver, 3);
    wait.until(ExpectedConditions.visibilityOf(location));
}

From source file:com.hotwire.selenium.desktop.us.partners.HotelTrivagoPage.java

License:Open Source License

public HotelTrivagoPage(WebDriver webdriver) {
    super(webdriver);
    WebDriverWait wait = new WebDriverWait(webdriver, 3);
    wait.until(ExpectedConditions.visibilityOf(location));
}

From source file:com.hotwire.selenium.desktop.us.search.AirSearchFragment.java

License:Open Source License

public AirSearchFragment addMoreFlights(String departure1, String arrival1, Date date1, String departure2,
        String arrival2, Date date2) {
    if (departure1 != null) {
        addMoreFlights.click();/*w w  w .ja  v  a  2 s .  co  m*/

        new WebDriverWait(getWebDriver(), MENU_VISIBLE_WAIT)
                .until(ExpectedConditions.visibilityOf(fromLocationForRoute3));

        sendKeys(fromLocationForRoute3, departure1);
        sendKeys(toLocationForRoute3, arrival1);
        sendKeys(startDateForRoute3, (new SimpleDateFormat("MM/dd/yy")).format(date1) + Keys.TAB);

        sendKeys(fromLocationForRoute4, departure2);
        sendKeys(toLocationForRoute4, arrival2);
        sendKeys(startDateForRoute4, (new SimpleDateFormat("MM/dd/yy")).format(date2) + Keys.TAB);
    }
    return new AirSearchFragment(getWebDriver());
}

From source file:com.hotwire.selenium.desktop.widget.AutoComplete.java

License:Open Source License

public AutoComplete(WebDriver webdriver, WebElement nativeDropDown) {
    this.webDriver = webdriver;
    this.nativeDropDown = nativeDropDown;
    new WebDriverWait(webDriver, TIMEOUT).until(ExpectedConditions.visibilityOf(nativeDropDown));
}

From source file:com.hotwire.selenium.desktop.widget.AutoComplete.java

License:Open Source License

List<WebElement> getCandidates() {
    try {// ww  w . j  a  va 2s .com

        WebElement container = getCandidateContainer();

        new WebDriverWait(webDriver, AUTOCOMPLETE_DISPLAY_TIMEOUT_SECONDS, AUTOCOMPLETE_POLLING_TIMEOUT_MS)
                .until(ExpectedConditions.visibilityOf(container));

        List<WebElement> out = container.findElements(AUTOCOMPLETE_CANDIDATES);
        LOGGER.info("candidates: {}", out.size());

        int total = 0;
        for (WebElement elm : out) {
            String innerText = elm.getText();
            if (StringUtils.isNoneBlank(innerText)) {
                LOGGER.info("{}", innerText);
                total++;
            }
        }

        LOGGER.info("Found {} candidates..", total);

        if (total > 0) {
            return out;
        }
    } catch (NoSuchElementException | TimeoutException e) {
        LOGGER.info("Autocomplete layout didn't appear..");
    }
    return null;
}

From source file:com.hotwire.selenium.desktop.widget.DatePicker.java

License:Open Source License

public void selectDateLegacyCalendar(Date d) {
    //make sure we advance to the correct month before showing the calendar
    JavascriptExecutor jsExecutor = (JavascriptExecutor) getWebDriver();
    String inputElementId = inputElement.getAttribute("id");
    jsExecutor.executeScript("var cal = CompSupport.getJsObj('" + inputElementId
            + "'); cal.yCal.cfg.setProperty('pagedate', new Date(" + d.getTime()
            + ")); cal.renderRequired=true;");

    inputElement.click();//from   w w  w . j  ava  2  s  .  c o m

    //block/wait until the calendar layer is actually visible
    new Wait<WebElement>(ExpectedConditions.visibilityOf(datePickerContainer)).maxWait(MAX_WAIT)
            .apply(getWebDriver());

    Calendar cal = GregorianCalendar.getInstance();
    cal.setTime(d);

    StringBuilder cssSelectorForAnchor = new StringBuilder();
    cssSelectorForAnchor.append("#").append(datePickerContainer.getAttribute("id")).append(" ");
    cssSelectorForAnchor.append(".m").append(cal.get(Calendar.MONTH) + 1).append(" ");
    cssSelectorForAnchor.append(".d").append(cal.get(Calendar.DAY_OF_MONTH)).append(" a");

    WebElement anchor = datePickerContainer.findElement(By.cssSelector(cssSelectorForAnchor.toString()));

    anchor.click();

    //block/wait until the text is actually placed in the input field and the calendar is hidden
    new WebDriverWait(getWebDriver(), MAX_WAIT)
            .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(CSS_CALENDAR)));
}

From source file:com.hotwire.selenium.desktop.widget.DatePicker.java

License:Open Source License

public void selectDateJQueryCalendar(Date d) {
    //make sure we advance to the correct month before showing the calendar
    JavascriptExecutor jsExecutor = (JavascriptExecutor) getWebDriver();
    String inputElementId = inputElement.getAttribute("id");
    jsExecutor.executeScript(/*  w  ww.j  a v  a2 s. com*/
            "$('#" + inputElementId + "').datepicker('setDate', new Date(" + d.getTime() + "));");

    inputElement.click();

    //block/wait until the calendar layer is actually visible
    new WebDriverWait(getWebDriver(), MAX_WAIT).until(ExpectedConditions.visibilityOf(datePickerContainer));

    Calendar cal = Calendar.getInstance();
    cal.setTime(d);

    String fmt = ".//table[@class='ui-datepicker-calendar']//td[@data-year='%d'][@data-month='%d']//a[text()='%d']";
    WebElement anchor = datePickerContainer.findElement(By.xpath(String.format(fmt, cal.get(Calendar.YEAR),
            cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH))));

    anchor.click();

    //block/wait until the text is actually placed in the input field and the calendar is hidden
    new WebDriverWait(getWebDriver(), MAX_WAIT)
            .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(CSS_CALENDAR)));
}

From source file:com.hotwire.selenium.mobile.widget.DatePicker.java

License:Open Source License

public void selectDate(Date d) {
    inputElement.click(); //force the datepicker open

    //block/wait until the calendar layer is actually visible
    new Wait<WebElement>(ExpectedConditions.visibilityOf(datePickerContainer)).maxWait(5).apply(getWebDriver());

    //force set a date
    JavascriptExecutor jsExecutor = (JavascriptExecutor) getWebDriver();
    String id = inputElement.getAttribute("id");
    jsExecutor.executeScript("$('#" + id + "').datepicker('setDate', new Date(" + d.getTime() + "));$('#" + id
            + "').datepicker('hide');");

    //block/wait until the text is actually placed in the input field and the calendar is hidden
    new Wait<Boolean>(new InvisibilityOf(datePickerContainer)).maxWait(15).apply(getWebDriver());
}