Example usage for org.openqa.selenium WebElement isDisplayed

List of usage examples for org.openqa.selenium WebElement isDisplayed

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement isDisplayed.

Prototype

boolean isDisplayed();

Source Link

Document

Is this element displayed or not?

Usage

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

License:Open Source License

public List<String> getMessages() {
    List<String> messages = new ArrayList<>();
    List<WebElement> webElementList = getMessageBlock();

    if (messageType.toString().equals("priceCheck")) {
        for (WebElement blk : webElementList) {
            if (blk.isDisplayed()) {
                messages.add(blk.getText().trim());
            }/*  www  .  j av  a 2 s. co  m*/
        }
    } else {
        for (WebElement blk : webElementList) {
            if (blk.isDisplayed()) {
                for (WebElement el : blk.findElements(By.cssSelector("ul li"))) {
                    messages.add(el.getText().trim());
                }
            }
        }
    }
    return messages;
}

From source file:com.hotwire.selenium.mobile.account.mytrips.MobileFlightTripDetailsPage.java

License:Open Source License

@Override
public void verifyTripDetailsPage() {
    assertThat(tripDetails.isDisplayed())
            .as("Expected Trip Details to be displayed on the Flight Trip Details Page").isTrue();

    assertThat(confirmationNumbers.isDisplayed())
            .as("Expected Confirmation Numbers to be displayed on the Flight Trip Details Page").isTrue();

    assertThat(flightDetails.isDisplayed())
            .as("Expected Flight Details to be displayed on the Flight Trip Details Page").isTrue();

    assertThat(passengerInformation.isDisplayed())
            .as("Expected Passenger Information to be displayed on the Flight Trip Details Page").isTrue();

    for (WebElement element : carrierPhoneNumbers) {
        assertThat(element.isDisplayed()).as(
                "Expected at least one Carrier Phone Number to be displayed on the Flight Trip Details Page")
                .isTrue();/*ww  w  .  j  a  v  a  2s . c o  m*/
    }
}

From source file:com.hotwire.selenium.mobile.billing.AbstractPaymentMethodFragment.java

License:Open Source License

public AbstractPaymentMethodFragment setState(String state, String country) {
    boolean isSelect = true;
    WebElement element;
    if (country.equalsIgnoreCase("united states")) {
        element = this.state;
    } else if (country.equalsIgnoreCase("canada")) {
        element = getWebDriver().findElement(By.cssSelector("select[id='province']"));
    } else if (country.equalsIgnoreCase("australia")) {
        element = getWebDriver().findElement(By.cssSelector("select[id='auProvince']"));
    } else {/*from   w  w w  .  j a  va2s .c  o  m*/
        element = getWebDriver().findElement(By.cssSelector("input[id='other']"));
        isSelect = false;
    }
    if (!element.isDisplayed()) {
        return this;
    }

    if (!isSelect) {
        element.sendKeys(state);
    } else {
        if (element.isDisplayed()) {
            Select select = new Select(element);
            try {
                int index = Integer.parseInt(state);
                select.selectByIndex(index);
            } catch (NumberFormatException e) {
                select.selectByValue(state);
            }
        }
    }
    return this;
}

From source file:com.hotwire.selenium.mobile.billing.AbstractPaymentMethodFragment.java

License:Open Source License

protected void submitData(String ccNumber, String ccExpMonth, String ccExpYear, String securityCode,
        String firstName, String lastName, String billingAddress, String country, String city, String state,
        String zipCode) {//from   www .j av  a 2 s. com

    new Select(this.country).selectByVisibleText(country);
    this.ccNumber.clear();
    this.ccNumber.sendKeys(ccNumber);
    new Select(this.ccExpMonth).selectByVisibleText(ccExpMonth);
    new Select(this.ccExpYear).selectByVisibleText(ccExpYear);
    this.securityCode.clear();
    this.securityCode.sendKeys(securityCode);
    this.firstName.clear();
    this.firstName.sendKeys(firstName);
    this.lastName.clear();
    this.lastName.sendKeys(lastName);
    if (this.billingAddress.isDisplayed()) {
        this.billingAddress.clear();
        this.billingAddress.sendKeys(billingAddress);
    }
    if (this.city.isDisplayed()) {
        this.city.clear();
        this.city.sendKeys(city);
    }
    WebElement element;
    boolean isSelect = true;
    if (country.equalsIgnoreCase("united states")) {
        element = this.state;
    } else if (country.equalsIgnoreCase("canada")) {
        element = getWebDriver().findElement(By.cssSelector("select[id='province']"));
    } else if (country.equalsIgnoreCase("australia")) {
        element = getWebDriver().findElement(By.cssSelector("select[id='auProvince']"));
    } else {
        element = getWebDriver().findElement(By.cssSelector("input[id='other']"));
        isSelect = false;
    }
    if (!isSelect) {
        element.sendKeys(state);
    } else {
        if (element.isDisplayed()) {
            Select select = new Select(element);
            try {
                int index = Integer.parseInt(state);
                select.selectByIndex(index);
            } catch (NumberFormatException e) {
                select.selectByValue(state);
            }
        }
    }
    this.zipCode.clear();
    this.zipCode.sendKeys(zipCode);
}

From source file:com.hotwire.selenium.mobile.billing.MobileBillingPg.java

License:Open Source License

public boolean isAccessibilityOptionsDisplayed() {
    for (WebElement element : accessibilityCheckboxes) {
        try {//from w  w  w . j ava2 s  .c  o  m
            if (!element.isDisplayed()) {
                return false;
            }
        } catch (NoSuchElementException e) {
            return false;
        }
    }
    return true;
}

From source file:com.hotwire.selenium.tools.c3.customer.C3PastBookingPage.java

License:Open Source License

public String getConfirmationMessage() throws Exception {
    new WebDriverWait(getWebDriver(), 20)
            .until(new IsElementLocationStable(getWebDriver(), By.cssSelector(CSS_CONFIRMATION_MSG), 10));
    List<WebElement> msg = findMany(CSS_CONFIRMATION_MSG);
    for (WebElement elem : msg) {
        if (elem.isDisplayed()) {
            return elem.getText();
        }//  w w w . j a v a2  s. c o  m
    }
    throw new Exception("Locator for the confirmation message was not found");
}

From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java

License:Open Source License

public C3AirMultiPassengerInfoFragment fillGuestName() {
    for (WebElement name : findMany("div#travelers div.name input")) {
        if (name.isDisplayed()) {
            name.sendKeys("Test" + RandomStringUtils.randomAlphabetic(5));
        }//from  ww w .  j  a  v  a 2  s .  c om
    }
    return this;
}

From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java

License:Open Source License

public C3AirMultiPassengerInfoFragment fillGender() {
    for (WebElement gender : findMany("ul.gender input#male")) {
        if (gender.isDisplayed()) {
            gender.click();/*from www .  ja v a  2 s  .c om*/
        }
    }
    return this;
}

From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java

License:Open Source License

public C3AirMultiPassengerInfoFragment fillBirthDay() {
    for (WebElement birthRow : findMany("div#dobRowId")) {
        if (birthRow.isDisplayed()) {
            setDate(birthRow, "select[id*='travelerForm.psgrDobMonth'] option[value='1']");
            setDate(birthRow, "select[id*='travelerForm.psgrDobDay'] option[value='1']");
            setDate(birthRow, "select[id*='travelerForm.psgrDobYear'] option[value='1980']");
        }// www . ja v a 2  s. co m
    }
    return this;
}

From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java

License:Open Source License

/**
 * Fill email and confirmation email/* w  w w .  j a  v  a2 s.c  om*/
 */
public C3AirMultiPassengerInfoFragment fillEmails(String email) {
    for (WebElement emailField : findMany("input.email")) {
        if (emailField.isDisplayed()) {
            emailField.sendKeys(email);
        }
    }
    return this;
}