Example usage for org.openqa.selenium By className

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

Introduction

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

Prototype

public static By className(String className) 

Source Link

Document

Find elements based on the value of the "class" attribute.

Usage

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

License:Open Source License

/**
 * Increase set point./* w  ww  . ja  va  2s  .co m*/
 * @param setPoint the set point
 */
private void increaseSetPoint(final Integer setPoint) {

    LogUtil.setLogString("Increase set point of: " + setPoint, true, CustomLogLevel.LOW);
    /*
     * WebElement upElement = getElement(getDriver(), By.className("upArrowButton"),
     * TINY_TIMEOUT);
     */
    // System.out.println("upElement" + upElement.getAttribute("class"));
    for (int i = 0; i < setPoint; i++) {

        getElement(getDriver(), By.className("upArrowButton"), TINY_TIMEOUT).click();
        LogUtil.setLogString("Clicked: " + i, true, CustomLogLevel.LOW);
        waitUntil(300);

        // upElement.click();

    }
}

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

License:Open Source License

/**
 * Decrease set point./*from   w  w  w. j  av a2 s.  co m*/
 * @param setPoint the set point
 */
private void decreaseSetPoint(final Integer setPoint) {

    LogUtil.setLogString("Decrease set point of: " + setPoint, true, CustomLogLevel.LOW);

    /*
     * WebElement downArrowElement = getElementBySubElement(getDriver(),
     * getTstatSetPointContainer(), By.className("downArrowButton"), TINY_TIMEOUT);
     */

    for (int i = 0; i < -setPoint; i++) {

        getElement(getDriver(), By.className("downArrowButton"), TINY_TIMEOUT).click();
        LogUtil.setLogString("Clicked: " + i, true, CustomLogLevel.LOW);
        waitUntil(300);

    }
}

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

License:Open Source License

/**
 * Click mode heat.//from ww  w. j a  v a 2  s . c  o  m
 */
public void clickModeHeat() {

    LogUtil.setLogString("Click mode heat", true, CustomLogLevel.MEDIUM);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(), By.className(HVAC_MODE_BTN),
            TINY_TIMEOUT);
    WebElement heatModeElement = getCurrentThermostatContainer();
    List<WebElement> thermostatElementList = getElementsBySubElement(getDriver(), heatModeElement,
            By.className(HVAC_MODE_BTN), TINY_TIMEOUT);
    for (WebElement webElement : thermostatElementList) {
        if (webElement.getAttribute(ATTR_VALUE).equalsIgnoreCase(HEAT)) {
            getAction().click(webElement);
            break;
        }
    }
    getAction().rejectAlert();
    verifyIdleState();
    LogUtil.setLogString("Check color changed to Red", true, CustomLogLevel.MEDIUM);
    Assert.assertTrue(verifyColorChanges(HEAT_CONTAINER), "color is not changed");
}

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

License:Open Source License

/**
 * Click mode cool.//from  w  ww.j  av a2  s .c  o m
 */
public void clickModeCool() {

    LogUtil.setLogString("Click mode Cool", true, CustomLogLevel.MEDIUM);
    WebElement heatModeElement = getCurrentThermostatContainer();
    List<WebElement> thermostatElementList = getElementsBySubElement(getDriver(), heatModeElement,
            By.className(HVAC_MODE_BTN), MEDIUM_TIMEOUT);
    for (WebElement webElement : thermostatElementList) {
        if (webElement.getAttribute(ATTR_VALUE).equalsIgnoreCase(COOL)) {
            WaitUtil.oneSec();
            webElement.click();
            tinyWait();
            // getAction().click(webElement);
            break;
        }
    }
    getAction().rejectAlert();
    verifyIdleState();
    LogUtil.setLogString("Check color changed to blue", true, CustomLogLevel.MEDIUM);
    Assert.assertTrue(verifyColorChanges(COOL_CONTAINER), "color is not changed to blue");
}

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

License:Open Source License

/**
 * Click mode off.//from ww  w .  j a  va 2s .  co m
 */
public void clickModeOff() {

    LogUtil.setLogString("Click mode off", true, CustomLogLevel.LOW);
    WebElement offModeElement = getCurrentThermostatContainer();
    List<WebElement> thermostatElementList = getElementsBySubElement(getDriver(), offModeElement,
            By.className(HVAC_MODE_BTN), TINY_TIMEOUT);
    for (WebElement webElement : thermostatElementList) {
        if (webElement.getAttribute(ATTR_VALUE).equalsIgnoreCase(OFF)) {
            getAction().click(webElement);
            break;
        }
    }
}

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

License:Open Source License

/**
 * Checks if is pop up opened./*from   ww w .j ava 2s. c o  m*/
 * @return true, if is pop up opened
 * @see com.ecofactor.qa.automation.newapp.page.TstatControlOpsPage#isPopUpOpened()
 */
@Override
public boolean isPopUpOpened() {

    LogUtil.setLogString("Check thermostat control page is opened and not closed after few seconds", true,
            CustomLogLevel.LOW);
    WaitUtil.tinyWait();
    boolean isDisplayed = isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(TSTAT_CONTROLS_CLOSE_BTN), TINY_TIMEOUT);
    return isDisplayed;
}

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

License:Open Source License

/**
 * Click current temp./*ww w.  ja  va  2s. c  om*/
 */
private void clickCurrentTemp() {

    LogUtil.setLogString("Click CurrentTemperature", true, CustomLogLevel.MEDIUM);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(), By.className(CURRENT_TEMPERATURE),
            TINY_TIMEOUT);
    WebElement setPointElement = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(CURRENT_TEMPERATURE), TINY_TIMEOUT);
    try {
        getAction().click(setPointElement);
    } catch (Exception e) {
        LogUtil.setLogString("Cannot click current temperature (Exception : " + e.getMessage() + ")", true);
    }
}

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

License:Open Source License

/**
 * Gets the current temperature.//from  w w  w. j  a va  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;
}

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

License:Open Source License

/**
 * Gets the target temperature./* www.java2s  .co m*/
 * @return the target temperature
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatControlPage#getTargetTemperature()
 */
@Override
public String getTargetTemperature() {

    LogUtil.setLogString("Get Target temperature", true, CustomLogLevel.HIGH);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(), By.className(TH_TARGET_SETPOINT),
            TINY_TIMEOUT);
    WebElement tempDivEle = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(TH_TARGET_SETPOINT), MEDIUM_TIMEOUT);
    String target = tempDivEle.getText();
    LogUtil.setLogString("Target temperature : " + target, true, CustomLogLevel.HIGH);
    return target;
}

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

License:Open Source License

/**
 * Gets the current mode./*from  ww  w. ja  v  a  2s .  com*/
 * @return the current mode
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatControlPage#getCurrentMode()
 */
@Override
public String getCurrentMode() {

    String currentMode = "";
    LogUtil.setLogString("Get Current Mode", true, CustomLogLevel.HIGH);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(THERMOSTAT_BTN_CONTAINER), TINY_TIMEOUT);
    WebElement thermostatElement = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector("." + THERMOSTAT_BTN_CONTAINER), TINY_TIMEOUT);
    List<WebElement> thermostatElementList = getElementsBySubElement(getDriver(), thermostatElement,
            By.cssSelector("." + HVAC_MODE_BTN), TINY_TIMEOUT);
    for (WebElement webElement : thermostatElementList) {
        String currentClass = webElement.getAttribute(ATTR_CLASS);
        if (currentClass.contains(SELECTED)) {
            currentMode = webElement.getAttribute(ATTR_VALUE);
            break;
        }
    }
    LogUtil.setLogString("Current Mode is :" + currentMode, true);
    return currentMode;

}