Example usage for org.openqa.selenium WebElement getText

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

Introduction

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

Prototype

String getText();

Source Link

Document

Get the visible (i.e.

Usage

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

License:Open Source License

/**
 * Gets the password requirement error msg.
 * @return the password requirement error msg
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getPasswordRequirementErrorMsg()
 *///from w  ww.  j a v a2  s  .  co  m
@Override
public void getPasswordRequirementErrorMsg() {

    setLogString("Get Password Requirement error message", true, CustomLogLevel.LOW);
    final WebElement msgElement = getElement(getDriver(), By.cssSelector(PASSWORD_ERROR_MESSAGE), TINY_TIMEOUT);
    Assert.assertTrue(PASSWORD_REQUIREMENT_MESSAGE.equalsIgnoreCase(msgElement.getText()));
    setLogString("Password Requirement error message : " + msgElement.getText(), true, CustomLogLevel.LOW);
}

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

License:Open Source License

/**
 * @return//from w ww .  j a v a 2s . co m
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getCurrentPwdErrorMsg()
 */
@Override
public String getCurrentPwdErrorMsg() {

    final WebElement currentPwdError = getElement(getDriver(), By.cssSelector(CURRENT_PASSWD_ERROR),
            TINY_TIMEOUT);
    setLogString("Current Password Error : " + currentPwdError.getText(), true, CustomLogLevel.LOW);
    return currentPwdError.getText();
}

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

License:Open Source License

/**
 * @return/*w  w w  . j  a  v a2  s  . c o  m*/
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getInvalidPwdErrorMsg()
 */
@Override
public String getInvalidPwdErrorMsg() {

    final WebElement invalidPwdError = getElement(getDriver(), By.cssSelector(NEW_PASSWD_ERROR), TINY_TIMEOUT);
    setLogString("Invalid Password Error : " + invalidPwdError.getText(), true, CustomLogLevel.LOW);
    return invalidPwdError.getText();
}

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

License:Open Source License

/**
 * @return/*w  w  w .ja v  a2 s  .  com*/
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getConfirmPwdErrorMsg()
 */
@Override
public String getConfirmPwdErrorMsg() {

    final WebElement repeatPwdError = getElement(getDriver(), By.cssSelector(CONFIRM_PASSWD_ERROR),
            TINY_TIMEOUT);
    setLogString("Repeat Password Error : " + repeatPwdError.getText(), true, CustomLogLevel.LOW);
    return repeatPwdError.getText();
}

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

License:Open Source License

/**
 * Checks if is content displayed.//ww  w  .j  av  a  2s .  c  o  m
 * @return true, if is content displayed
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatEEUIPage#isContentDisplayed()
 */
@Override
public boolean isContentDisplayed() {

    setLogString("is EE Description Content present?", true);
    WebElement contentElement = getElement(getDriver(), By.className(TEXT_CONTAINER), TINY_TIMEOUT);
    if (contentElement != null) {

        WebElement paragraph = getElementBySubElement(getDriver(), contentElement, By.tagName("p"),
                TINY_TIMEOUT);
        if (paragraph != null && paragraph.getText() != null && paragraph.getText().length() > 0) {
            setLogString("EE Description is displayed", true);
            setLogString("EE Description is:\n" + contentElement.getText(), true, CustomLogLevel.HIGH);
            return true;
        }
    }
    return false;
}

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

License:Open Source License

/**
 * Checks if is inside temp displayed./* w ww  .jav a 2  s . c o  m*/
 * @return true, if is inside temp displayed
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatPageUI#isInsideTempDisplayed()
 */
@Override
public boolean isInsideTempDisplayed() {

    setLogString("Check inside temperature is displayed.", true, CustomLogLevel.MEDIUM);
    final boolean isInsideTempDisplayed = isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector("div.currentTemperature"), TINY_TIMEOUT);
    final WebElement insideTemp = getElement(getDriver(), By.cssSelector("div.currentTemperature"),
            TINY_TIMEOUT);
    setLogString("Inside temperature is :" + insideTemp.getText(), true, CustomLogLevel.MEDIUM);
    return isInsideTempDisplayed;
}

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

License:Open Source License

/**
 * Gets the current location name./*  ww w.j a  v a 2 s .c  o  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 current thermostat name.//w  w  w .  j a va 2  s .com
 * @return the current thermostat name
 */
@Override
public String getCurrentThermostatName() {

    String name = "";
    final WebElement locationName = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(LOCATION_NAME), TINY_TIMEOUT);

    final String tstDetails = locationName.getText();
    if (tstDetails.contains("-")) {
        final int tstaNameIndex = tstDetails.lastIndexOf("-");
        name = tstDetails.substring(0, tstaNameIndex);
        setLogString("Current Thermostat Name : " + name, true, CustomLogLevel.HIGH);
    }
    return name;
}

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

License:Open Source License

/**
 * Gets the current temperature./*from  www .ja  va2 s  .  co m*/
 * @return the current temperature
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#getCurrentTemperature()
 */
@Override
public String getCurrentTemperature() {

    setLogString("Get current temperature", true, CustomLogLevel.HIGH);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(), By.className(CURRENT_TEMPERATURE),
            TINY_TIMEOUT);
    final WebElement currentTempElement = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(CURRENT_TEMPERATURE), TINY_TIMEOUT);
    Assert.assertNotNull(currentTempElement.getText(), "Current Temperature is not displayed");
    setLogString("Current Temperature: " + currentTempElement.getText(), true, CustomLogLevel.HIGH);
    final String currentTemperature = currentTempElement.getText().toString();
    return currentTemperature;
}

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

License:Open Source License

/**
 * @param expectedTemp/*from w ww . ja  v  a 2  s. co m*/
 * @return
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatPageUI#isTargetTemperatureChanged(java.lang.String)
 */
public boolean isTargetTemperatureChanged(final String expectedTemp) {

    setLogString("Check target temperature is changed to : " + expectedTemp, true, CustomLogLevel.HIGH);
    final boolean targetReflected = new WebDriverWait(getDriver(), CustomTimeout.VERY_LONG_TIMEOUT.getValue())
            .until(new ExpectedCondition<Boolean>() {
                @Override
                public Boolean apply(final WebDriver driver) {

                    final WebElement targetElement = getElementBySubElement(getDriver(),
                            getCurrentThermostatContainer(), By.cssSelector(SETPOINT), TINY_TIMEOUT);
                    if (targetElement.getText().equalsIgnoreCase(expectedTemp)) {
                        return true;
                    }
                    return false;
                }
            });
    return targetReflected;
}