Example usage for org.openqa.selenium By cssSelector

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

Introduction

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

Prototype

public static By cssSelector(String cssSelector) 

Source Link

Document

Find elements via the driver's underlying W3C Selector engine.

Usage

From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java

License:Open Source License

/**
 * Gets the last page no./*from  w w w .j  a  v  a  2s . c  o  m*/
 * @return the last page no
 * @see com.ecofactor.qa.automation.insite.page.UserManagement#getLastPageNo()
 */
@Override
public int getLastPageNo() {

    WebElement element = DriverConfig.getDriver()
            .findElement(By.cssSelector("input.pagedisplay.ef_smallLabel.ieFix"));
    String pageNo = element.getAttribute(ATTR_VALUE).split(" ")[0];
    DriverConfig.setLogString("Last Page No : " + pageNo, true);
    return Integer.valueOf(pageNo);
}

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

License:Open Source License

/**
 * Gets the current thermostat container.
 * @return the current thermostat container
 *//*  ww w.  j  a v a  2 s .com*/
public WebElement getCurrentThermostatContainer() {

    // isDisplayed(getDriver(), By.cssSelector(TSTAT_CONTAINER), TINY_TIMEOUT);
    final List<WebElement> elementList = getElements(getDriver(), By.cssSelector(TSTAT_CONTAINER),
            TINY_TIMEOUT);
    for (final WebElement webElement : elementList) {
        return webElement;

    }
    return null;
}

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

License:Open Source License

/**
 * Gets the current thermostat Button container.
 * @return the current thermostat button container.
 *///from  w w  w  .j a  va2  s. c  om
public WebElement getThermostatButtonContainer() {

    final List<WebElement> elementList = getElements(getDriver(), By.cssSelector(THERMOSTAT_BUTTON_CONTAINER),
            TINY_TIMEOUT);
    for (final WebElement webElement : elementList) {
        return webElement;

    }
    return null;
}

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

License:Open Source License

/**
 * Gets the toast error message./*  w  w  w. j  a  v a 2  s . c o 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.AbstractSetAwayParameters.java

License:Open Source License

/**
 * Save away settings./*from   w w w  .ja v  a2s .  c om*/
 * @return true, if successful
 */
protected boolean saveAwaySettings() {

    final WebElement setElement = getElement(getDriver(), By.cssSelector("a.dwb.dwb0.dwb-e"), TINY_TIMEOUT);
    getAction().click(setElement);

    return isNotDisplayed(getDriver(), By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Close away settings popup./*  ww  w.  ja v a  2 s. c  o m*/
 */
protected boolean cancelAwaySettings() {

    final WebElement cancelElement = getElement(getDriver(), By.cssSelector("a.dwb.dwb1.dwb-e"),
            MEDIUM_TIMEOUT);
    getAction().click(cancelElement);
    return isNotDisplayed(getDriver(), By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Change value.//from  w  ww.j  ava2 s. co  m
 * @param value the value
 * @return the integer
 */
public Integer changeAwayParamValue(final SetAwayParams awayParams, final int value) {

    final int noOfSetPoints = Math.abs(value);

    WebElement containerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl0"), TINY_TIMEOUT);

    WebElement currentReadingElement = getElementBySubElement(getDriver(), containerElement,
            By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT);
    String currentReadingValue = currentReadingElement.getAttribute(DATA_VALUE);

    final WebElement upOrDownArrow = value > 0
            ? getElementBySubElement(getDriver(), containerElement, By.cssSelector("a.dwb-e.dwwb.dwwbm"),
                    SHORT_TIMEOUT)
            : getElementBySubElement(getDriver(), containerElement, By.cssSelector("a.dwb-e.dwwb.dwwbp"),
                    SHORT_TIMEOUT);

    for (int count = 0; count < noOfSetPoints; count++) {
        getAction().click(upOrDownArrow);
    }

    currentReadingElement = getElementBySubElement(getDriver(), containerElement, By.cssSelector(CURRENT_VALUE),
            TINY_TIMEOUT);
    currentReadingValue = currentReadingElement.getAttribute(DATA_VALUE);

    saveAwaySettings();
    return Integer.parseInt(currentReadingValue);
}

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

License:Open Source License

/**
 * Sets the away param picker./*from   w w w .  j  av  a2s  .  com*/
 * @param setAwayParams the set away params
 * @param expectedValue the expected value
 * @return true, if successful
 * @see com.ecofactor.qa.automation.newapp.page.AwaySettingsOpsPage#setAwayParam(com.ecofactor.qa.automation.newapp.enums.SetAwayParams,
 *      int)
 */
@Override
public boolean setAwayParamPicker(final SetAwayParams setAwayParams, final int expectedValue) {

    LogUtil.setLogString("Set " + setAwayParams + " as :" + expectedValue, true);

    final WebElement clickValue = getElement(getDriver(), By.cssSelector(".away_setting_picker"), TINY_TIMEOUT);
    WaitUtil.oneSec();
    getAction().click(clickValue);
    getAction().rejectAlert();

    final WebElement currentReadingElement = getElement(getDriver(), By.cssSelector(CURRENT_VALUE),
            TINY_TIMEOUT);

    final int currentReadingValue = Integer.parseInt(currentReadingElement.getAttribute(DATA_VALUE));

    final int setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue)
            : expectedValue - currentReadingValue;

    return changeAwayParamValue(setAwayParams, setPointValue).equals(expectedValue);
}

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

License:Open Source License

/**
 * Click away param picker.//w  w w .  ja v a  2 s .c om
 * @param setAwayParam the set away param
 * @return true, if successful
 * @see com.ecofactor.qa.automation.newapp.page.AwaySettingsOpsPage#clickAwayParam(com.ecofactor.qa.automation.newapp.enums.SetAwayParams)
 */
@Override
public boolean clickAwayParamPicker(final SetAwayParams setAwayParam) {

    final WebElement pickerElement = awaySettingsUIPage.getPickerElement(setAwayParam);
    Assert.assertTrue(isClickable(getDriver(), pickerElement, MEDIUM_TIMEOUT),
            setAwayParam + " field is not clickable.");
    getAction().click(pickerElement);
    return isDisplayed(getDriver(), By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Click away settings.//from  w w w.  j  a v  a2 s  . com
 * @see com.ecofactor.qa.automation.newapp.page.AwaySettingsOpsPage#setCoolTemp(java.lang.String)
 */
@Override
public void clickAwaySettings() {

    LogUtil.setLogString("Switch to Away Settings", true);
    isDisplayed(getDriver(), By.cssSelector(MENU_AWAY_SETTINGS), TINY_TIMEOUT);
    getAction().rejectAlert();
    final WebElement menuAwaySettingsElement = getElement(getDriver(), By.cssSelector(MENU_AWAY_SETTINGS),
            TINY_TIMEOUT);
    WaitUtil.oneSec();
    getAction().click(menuAwaySettingsElement);
    getAction().rejectAlert();
}