Example usage for org.openqa.selenium By tagName

List of usage examples for org.openqa.selenium By tagName

Introduction

In this page you can find the example usage for org.openqa.selenium By tagName.

Prototype

public static By tagName(String tagName) 

Source Link

Usage

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

License:Open Source License

/**
 * Checks if is content displayed.//from w  w  w  . ja v a  2  s.c  om
 * @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 idle state.//from www.j av a2s .c  o  m
 * @return true, if is idle state
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#isIdleState()
 */
@Override
public boolean isIdleState() {

    setLogString("Verify the state is neutral", true, CustomLogLevel.HIGH);
    final WebElement currentState = getElementByAttr(getDriver(), By.tagName(TAG_DIV), ATTR_CLASS, LEFT_NEUTRAL,
            SHORT_TIMEOUT);
    return currentState != null;
}

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

License:Open Source License

/**
 * Gets the temperature content by position.
 * @param position the position//from w w w.j  ava2s  .c  o  m
 * @return the temperature content by position
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#getTemperatureContentByPosition(java.lang.String)
 */
@Override
public String getTemperatureContentByPosition(String position) {

    final WebElement tempDifferenceContainer = getElement(getDriver(), By.className("temperatureDiffContainer"),
            TINY_TIMEOUT);
    final List<WebElement> divElements = getElementsBySubElement(getDriver(), tempDifferenceContainer,
            By.tagName("div"), TINY_TIMEOUT);

    WebElement requiredContainer = null;
    for (final WebElement element : divElements) {
        if (element.getAttribute("class").startsWith(position)) {
            requiredContainer = element;
            break;
        }
    }
    WebElement temperatureInfo = getElementBySubElementText(getDriver(), requiredContainer, By.tagName(TAG_DIV),
            "INSIDE", SHORT_TIMEOUT);
    temperatureInfo = (temperatureInfo != null) ? temperatureInfo
            : getElementBySubElementText(getDriver(), requiredContainer, By.tagName(TAG_DIV), "TARGET",
                    SHORT_TIMEOUT);
    return temperatureInfo.getText();
}

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

License:Open Source License

/**
 * Gets the tstat status message.// w  ww. j a  va  2  s . c om
 * @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.TstatControlOpsPageImpl.java

License:Open Source License

/**
 * Click fan on./*  www  .j  ava2 s  .c o m*/
 */
@Override
public void clickFanOn() {

    LogUtil.setLogString("Click Fan On", true, CustomLogLevel.LOW);
    WebElement fanOnElement = getElementBySubElementAttr(getDriver(), getCurrentThermostatContainer(),
            By.tagName(TAG_INPUT), ATTR_VALUE, FAN_ON, SHORT_TIMEOUT);
    getAction().click(fanOnElement);
}

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

License:Open Source License

/**
 * Click fan on./*from   w  w w.  j  av  a2  s .  c  om*/
 */
@Override
public void clickFanAuto() {

    LogUtil.setLogString("Click Fan Auto", true, CustomLogLevel.LOW);
    WebElement fanAutoElement = getElementBySubElementAttr(getDriver(), getCurrentThermostatContainer(),
            By.tagName(TAG_INPUT), ATTR_VALUE, AUTO, SHORT_TIMEOUT);
    getAction().click(fanAutoElement);
}

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

License:Open Source License

/**
 * Temporary method. Which we rechanged again.
 * @param url the url//from  w w  w  .  j  a v  a2  s. c  o  m
 * @param params the params
 * @param expectedStatus the expected status
 * @return the e eapi
 * @see com.ecofactor.qa.automation.newapp.page.TstatControlOpsPage#getEEapi(java.lang.String,
 *      java.util.Map, int)
 */
public String getEEapi(String url, Map<String, String> params, int expectedStatus) {

    String content = null;
    HttpGet request = new HttpGet(url);
    URIBuilder builder = new URIBuilder(request.getURI());

    if (params != null) {
        final Set<String> keys = params.keySet();
        for (String key : keys) {
            builder.addParameter(key, params.get(key));
        }
    }
    try {
        request.setURI(builder.build());
        DriverConfig.setLogString("URL " + request.getURI().toString(), true);
        getDriver().navigate().to(request.getURI().toString());
        largeWait();
        content = getDriver().findElement(By.tagName("Body")).getText();
        DriverConfig.setLogString("Content: " + content, true);
    } catch (Exception e) {
        e.printStackTrace();

    } finally {
        request.releaseConnection();
    }

    return content;

}

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

License:Open Source License

/**
 * Checks if is given mode selected./*from   ww  w. j  a va  2 s .  c o  m*/
 * @param mode the mode
 * @return true, if is given mode selected
 */
private boolean isGivenModeSelected(String mode) {

    boolean selected = false;
    WebElement element = getElementBySubElementAttr(getDriver(), getCurrentThermostatContainer(),
            By.tagName(TAG_INPUT), ATTR_VALUE, mode, MEDIUM_TIMEOUT);
    if (element.getAttribute("class").contains("selected")) {
        String modeValue = element.getAttribute("value").toLowerCase();
        if (modeValue.equalsIgnoreCase(mode)) {
            LogUtil.setLogString(mode + " mode is selected", true, CustomLogLevel.MEDIUM);
            selected = true;
        }
    }
    return selected;
}

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

License:Open Source License

/**
 * Checks if is fan on.//  ww  w .  j a  va2  s.c o  m
 * @return true, if is fan on
 * @see com.ecofactor.qa.automation.consumer.page.ConsumerHome#isFanOn()
 */
@Override
public boolean isFanOn() {

    WebElement fanOnElement = getElementBySubElementAttr(getDriver(), getCurrentThermostatContainer(),
            By.tagName(TAG_INPUT), ATTR_VALUE, FAN_ON, SHORT_TIMEOUT);
    boolean onSelected = fanOnElement.getAttribute("className").contains("selected");
    return onSelected;
}

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

License:Open Source License

/**
 * Gets the current temperature.//from w w w . jav a  2s . c  o  m
 * @return the current temperature
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatControlPage#getCurrentTemperature()
 */
@Override
public String getCurrentTemperature() {

    LogUtil.setLogString("Get Current temperature", true, CustomLogLevel.HIGH);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(), By.className(TH_TEMPERATURE_SMALL),
            TINY_TIMEOUT);
    WebElement tempDivEle = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(TH_TEMPERATURE_SMALL), MEDIUM_TIMEOUT);
    WebElement currentElement = getElementBySubElement(getDriver(), tempDivEle, By.tagName(TAG_SPAN),
            MEDIUM_TIMEOUT);
    String current = currentElement.getText();
    LogUtil.setLogString("Current temperature : " + current, true, CustomLogLevel.HIGH);
    return current;
}