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.ecofactor.qa.automation.insite.page.SupportLookUpImpl.java

License:Open Source License

/**
 * Verify consumer login./*from w ww  .  jav  a  2  s. co  m*/
 * @param userId the user id
 */
public void verifyConsumerLogin(String userId) {

    DriverConfig.setLogString("Check logout link is present", true);
    WebElement logoutLink = DriverConfig.getDriver()
            .findElement(By.cssSelector(loginConfig.get(CONSUMER_LOGOUT_LINK)));
    assertTrue(logoutLink.isDisplayed() && logoutLink.isEnabled(), "logout link is not available");

    DriverConfig.setLogString("Check welcome text in header contains " + userId, true);
    WebElement welcomeText = DriverConfig.getDriver()
            .findElement(By.cssSelector(loginConfig.get(CONSUMER_WELCOME_TEXT)));
    assertTrue(welcomeText.getText().contains(userId), "welcome text doesn't contain the user");

    user = userId;
    DriverConfig.setLogString("Login success for " + user, true);

}

From source file:com.ecofactor.qa.automation.newapp.page.impl.AbstractAuthenticationPageImpl.java

License:Open Source License

/**
 * Gets the toast error message./* w  ww. ja v a  2 s .co  m*/
 * @return the toast error message
 * @see com.ecofactor.qa.automation.newapp.page.BasePage#getToastErrorMessage()
 */
public String getToastErrorMessage() {

    tinyWait();
    final WebElement errorElement = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector(ERROR_MESSAGE), TINY_TIMEOUT);
    if (errorElement.isDisplayed()) {
        final String thStatusMsg = errorElement.getText().toString();
        setLogString("Thermostat Toast Error message:" + thStatusMsg, true);
        return thStatusMsg;
    }
    return null;
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.SavingsPageImpl.java

License:Open Source License

/**
 * Gets the tstat status message./*from   w w w .  ja  v a2  s.co  m*/
 * @return the tstat status message
 */
private String getTstatStatusMessage() {

    String thStatusMsg = null;
    WebElement modeDialog = getElement(getDriver(), By.cssSelector(MODEL_DIALOG), TINY_TIMEOUT);
    if (modeDialog.isDisplayed()) {
        WebElement modeMessage = getElementBySubElement(getDriver(), modeDialog, By.className(ERROR_MODEBOX),
                TINY_TIMEOUT);
        thStatusMsg = getElementBySubElement(getDriver(), modeMessage, By.className(MODEL_LABEL), TINY_TIMEOUT)
                .getText();
        setLogString("Location status message:" + thStatusMsg, true, CustomLogLevel.HIGH);
    }
    return thStatusMsg;
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatEEOpsPageImpl.java

License:Open Source License

/**
 * Click close./*from   ww w .j ava 2s. co m*/
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatEEOpsPage#clickClose()
 */
@Override
public void clickClose() {

    setLogString("Click Close button in EE", true);
    WebElement closeBtnElement = getElement(getDriver(), By.className(CLOSE_BTN), TINY_TIMEOUT);
    if (closeBtnElement != null && closeBtnElement.isDisplayed()) {
        getAction().click(closeBtnElement);
    }

}

From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatEEUIPageImpl.java

License:Open Source License

/**
 * Checks if is close button displayed./*from w w w  .  j  av a2s .c  om*/
 * @return true, if is close button displayed
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatEEUIPage#isCloseButtonDisplayed()
 */
@Override
public boolean isCloseButtonDisplayed() {

    setLogString("is Close Button Displayed in EE ?", true);
    WebElement closeBtnElement = getElement(getDriver(), By.className(CLOSE_BTN), TINY_TIMEOUT);
    if (closeBtnElement != null && closeBtnElement.isDisplayed()) {
        setLogString("Close Button is displayed", true);
        return true;
    }
    return false;
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java

License:Open Source License

/**
 * Checks if is mode off.//from  www.  j  av a2s . com
 * @return true, if is mode off
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#isModeOff()
 */
@Override
public boolean isModeOff() {

    setLogString("Verify the mode is off.", true, CustomLogLevel.MEDIUM);
    final WebElement currentMode = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector(OFF_MODE_BACK), TINY_TIMEOUT);
    return (currentMode != null && currentMode.isDisplayed()) ? true : false;
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java

License:Open Source License

/**
 * Gets the current location name.//from   w  ww  .  j  a v a  2s .  co  m
 * @return the current location name
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#getCurrentLocationName()
 */
@Override
public String getCurrentLocationName() {

    String name = "";
    final List<WebElement> themostatNameList = getElements(getDriver(), By.cssSelector(TSTAT_HEADER),
            TINY_TIMEOUT);
    for (final WebElement webElement : themostatNameList) {
        if (webElement.isDisplayed()) {
            final WebElement themostatName = getElementBySubElement(getDriver(),
                    getCurrentThermostatContainer(), By.className(LOCATION_NAME), TINY_TIMEOUT);
            final String locationName = themostatName.getText();
            if (locationName.contains("-")) {
                final int tstaNameIndex = locationName.lastIndexOf("-");
                name = locationName.substring(tstaNameIndex + 1, locationName.length());
                setLogString("Current Location Name : " + name, true, CustomLogLevel.HIGH);
            }
            break;
        }
    }
    return name;
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java

License:Open Source License

/**
 * Gets the tstat status message./*from  w  w w  .  jav  a2  s  .co m*/
 * @return the tstat status message
 */
private String getTstatStatusMessage() {

    String thStatusMsg = null;
    final WebElement errorElement = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector(ERROR_MODEBOX), TINY_TIMEOUT);
    if (errorElement.isDisplayed()) {
        final WebElement modeLabelelement = getElementBySubElement(getDriver(), errorElement,
                By.className(MODEL_LABEL), ATOMIC_TIMEOUT);
        thStatusMsg = getElementBySubElement(getDriver(), modeLabelelement, By.tagName(TAG_P), ATOMIC_TIMEOUT)
                .getText();
        setLogString("Thermostat status message:" + thStatusMsg, true, CustomLogLevel.HIGH);
    }
    return thStatusMsg;
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.TstatControlUIPageImpl.java

License:Open Source License

@Override
public boolean isSavingsEnergyLinkDisplayed() {

    LogUtil.setLogString("Check Savings Link/image is displayed", true, CustomLogLevel.MEDIUM);
    WebElement savingsElement = getElement(getDriver(), By.cssSelector(".eeTargetSetpoint.eeActive>img"),
            MEDIUM_TIMEOUT);//from  w  w w.  j a v a  2 s  .co m

    return savingsElement != null && savingsElement.isDisplayed();
}

From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java

License:Open Source License

/**
 * Checks if is displayed by list.//from  w  w  w  .j a v a  2  s . co m
 * @param driver the driver
 * @param locator the locator
 * @param timeout the timeout
 * @return true, if is displayed by list
 */
public static boolean isDisplayedByList(final WebDriver driver, final By locator, final CustomTimeout timeout) {

    boolean isLoaded = false;
    try {
        isLoaded = new WebDriverWait(driver, timeout.getValue()).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(final WebDriver driver) {

                final List<WebElement> elements = driver.findElements(locator);
                boolean displayed = false;
                for (final WebElement element : elements) {
                    displayed = element.isDisplayed();
                    if (displayed) {
                        break;
                    }
                }
                return displayed;
            }
        });
    } catch (TimeoutException te) {
        isLoaded = false;
    }
    return isLoaded;
}