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.newapp.page.impl.LocationSwitcherUIPageImpl.java

License:Open Source License

/**
 * Gets the temp by tstat id./*from   ww w  .  j  av a2  s.  c o m*/
 * @param tstatId the tstat id
 * @param tempType the temp type
 * @return the temp by tstat id
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getTempByTstatId(Integer,
 *      java.lang.String)
 */
@Override
public String getTempByTstatId(final Integer tstatId, final TemperatureType tempType) {

    LogUtil.setLogString("Get Temperature for tstatId :" + tstatId, true, CustomLogLevel.LOW);
    final WebElement tstatElement = getElementByAttr(getDriver(), By.cssSelector(THERMOSTAT_ROW), THERMOSTAT_ID,
            tstatId.toString(), SHORT_TIMEOUT);
    final WebElement statusElement = getElementBySubElement(getDriver(), tstatElement,
            By.className(THERMOSTAT_STATUS), SHORT_TIMEOUT);
    final String statusText = statusElement.getText();
    String temperature = "";
    if (statusText != null && !statusText.isEmpty() && !statusText.equals("--")) {
        temperature = getTemperature(tempType, temperature, statusText);
    } else if (statusText != null && !statusText.isEmpty() && statusText.equals("--")) {
        temperature = "--";
    }
    LogUtil.setLogString("The Temperature is :" + temperature, true, CustomLogLevel.LOW);
    return temperature;
}

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

License:Open Source License

/**
 * Gets the tstat namesin location.//w w  w.  ja  v  a2 s . c  o  m
 * @param locId the loc id
 * @return the tstat namesin location
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getTstatNamesinLocation(Integer)
 */
@Override
public List<String> getTstatNamesinLocation(final Integer locId) {

    LogUtil.setLogString("Get Thermostat Names for location id :" + locId, true, CustomLogLevel.LOW);
    final WebElement thermostatSwitcherContainer = getElement(getDriver(),
            By.className(THERMOSTAT_SWITCHER_CONTAINER), SHORT_TIMEOUT);
    final List<WebElement> tstatName = getElementsBySubElement(getDriver(), thermostatSwitcherContainer,
            By.cssSelector(THERMOSTAT_ROW), SHORT_TIMEOUT);
    final List<String> tstatNames = new ArrayList<String>();
    for (final WebElement element1 : tstatName) {
        final String locId1 = element1.getAttribute(LOCATION_ID);
        if (locId1.equalsIgnoreCase(String.valueOf(locId))) {
            final WebElement tstatName1 = getElementBySubElement(getDriver(), element1,
                    By.className(THERMOSTAT_NAME), SHORT_TIMEOUT);
            tstatNames.add(tstatName1.getText());
        }
    }
    return tstatNames;
}

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

License:Open Source License

/**
 * Gets the tstat id for location.//from   w  w w  . j a  v a  2 s .  c o m
 * @param locId the loc id
 * @return the tstat id for location
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getTstatIdForLocation(java.lang.Integer)
 */
@Override
public List<Integer> getTstatIdForLocation(final Integer locId) {

    LogUtil.setLogString("Get Thermostat Id for location id :" + locId, true, CustomLogLevel.LOW);
    final WebElement thermostatSwitcherContainer = getElement(getDriver(),
            By.className(THERMOSTAT_SWITCHER_CONTAINER), SHORT_TIMEOUT);
    final List<WebElement> tstatName = getElementsBySubElement(getDriver(), thermostatSwitcherContainer,
            By.cssSelector(THERMOSTAT_ROW), SHORT_TIMEOUT);
    final List<Integer> tstatIdList = new ArrayList<Integer>();
    for (final WebElement element1 : tstatName) {
        final String locId1 = element1.getAttribute(LOCATION_ID);
        if (locId1.equalsIgnoreCase(String.valueOf(locId))) {
            final Integer tstatId = Integer.valueOf(element1.getAttribute(THERMOSTAT_ID));
            tstatIdList.add(tstatId);
        }
    }
    return tstatIdList;
}

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

License:Open Source License

/**
 * Gets the mode by tstat id.//from   w  w w .  j a  v a  2s. co  m
 * @param tstatId the tstat id
 * @return the mode by tstat id
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getModeByTstatId(Integer)
 */
@Override
public String getModeByTstatId(final Integer tstatId) {

    LogUtil.setLogString("Get Mode for thermostat :" + tstatId, true, CustomLogLevel.LOW);
    final WebElement tstatElement = getElementByAttr(getDriver(), By.cssSelector(THERMOSTAT_ROW), THERMOSTAT_ID,
            tstatId.toString(), SHORT_TIMEOUT);
    String className = tstatElement.getAttribute(CLASS);
    Object val = null;
    if (className != null && className.contains(" ")) {
        int spaceIndex = className.lastIndexOf(" ");
        className = className.substring(spaceIndex, className.length());
        LogUtil.setLogString("Get the icon displayed for thermostat " + tstatId, true, CustomLogLevel.LOW);
        val = executeScriptByClassName(className, BACKGROUND_IMG, getDriver());
        LogUtil.setLogString("Icon Displayed " + val.toString(), true, CustomLogLevel.LOW);
    } else {
        val = executeScriptByClassName(className, BACKGROUND_IMG, getDriver());
        if (val == null) {
            val = "";
        }
        LogUtil.setLogString("Icon Displayed " + val.toString(), true, CustomLogLevel.LOW);
    }
    return getMode(val.toString());
}

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

License:Open Source License

/**
 * Gets the rangeof temperature./*ww  w . j  a  v  a 2 s  . c om*/
 * @param tstatId the tstat id
 * @return the rangeof temperature
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getRangeofTemperature(java.lang.Integer)
 */
@Override
public String getRangeofTemperature(Integer tstatId) {

    LogUtil.setLogString("Get Range of Temperature for thermostat :" + tstatId, true, CustomLogLevel.LOW);
    final WebElement tstatElement = getElementByAttr(getDriver(), By.cssSelector(THERMOSTAT_ROW), THERMOSTAT_ID,
            tstatId.toString(), SHORT_TIMEOUT);
    final WebElement tstatStatusElement = getElementBySubElement(getDriver(), tstatElement,
            By.className(THERMOSTAT_STATUS), SHORT_TIMEOUT);
    String statusText = tstatStatusElement.getText();
    if (statusText.equalsIgnoreCase("--")) {

        LogUtil.setLogString("The Range is " + statusText, true, CustomLogLevel.LOW);
    } else if (statusText != null && !statusText.isEmpty() && !statusText.equalsIgnoreCase("--")) {
        statusText = getRange(statusText);
        LogUtil.setLogString("The Range is " + statusText, true, CustomLogLevel.LOW);
    }

    return statusText;
}

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

License:Open Source License

/**
 * verify either need help link clicked or not.
 * @see com.ecofactor.qa.automation.newapp.page.LoginPage#clickNeedHelp()
 *//*from   www . j av a  2  s .c om*/
@Override
public void clickNeedHelp() {

    LogUtil.setLogString("Check for Need Help Hyper Link", true);

    LogUtil.setLogString("Password Page", true);
    final WebElement needForHelpLink = getElement(getDriver(), By.cssSelector(NEED_HELP_LINK), MEDIUM_TIMEOUT);
    getAction().click(needForHelpLink);
    WaitUtil.tinyWait();
    getAction().rejectAlert();
}

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

License:Open Source License

/**
 * verify either back button clicked or not.
 * @see com.ecofactor.qa.automation.newapp.page.LoginPage#clickBackButton()
 *///from  ww w .  j av  a2s.c  o m
@Override
public void clickBackButton() {

    LogUtil.setLogString("Click Back button", true);
    final WebElement backButton = getElement(getDriver(), By.cssSelector(BACK_BUTTON), MEDIUM_TIMEOUT);
    getAction().click(backButton);
    WaitUtil.tinyWait();
    getAction().rejectAlert();
    LogUtil.setLogString("Back to Login Page", true);
}

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

License:Open Source License

/**
 * Click the menu icon from the thermostat page.
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickMenuIcon()
 *//*  www  .  ja v  a 2 s.  c  o  m*/
@Override
public void clickMenuIcon() {

    getAction().rejectAlert();
    setLogString("Check Menu Icon is Displayed", true);
    isDisplayed(getDriver(), By.cssSelector(MENU_ICON), SHORT_TIMEOUT);
    setLogString("Click Menu Icon in Slice", true);
    getAction().rejectAlert();
    final WebElement menuIcon = getElement(getDriver(), By.cssSelector(MENU_ICON), SHORT_TIMEOUT);
    menuIcon.click();
    // getAction().click(menuIcon);
    WaitUtil.oneSec();
    getAction().rejectAlert();

}

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

License:Open Source License

/**
 * Click the thermostat menu item from the menu page.
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickThermostatMenuItem()
 *///from w  w w.j a  v  a  2  s. co  m
@Override
public void clickThermostatMenuItem() {

    WaitUtil.tinyWait();
    setLogString("Check Thermostat Menu Item is Displayed", true);
    final boolean state = isDisplayed(getDriver(), By.cssSelector(THERMOSTAT_MENU_ITEM), TINY_TIMEOUT);
    if (state) {

        final WebElement menuIcon = getElement(getDriver(), By.cssSelector(THERMOSTAT_MENU_ITEM), TINY_TIMEOUT);
        menuIcon.click();
        setLogString("Thermostat Menu Item is Clicked", true);
        // getAction().click(menuIcon);
        getAction().rejectAlert();
    } else {

        setLogString("Thermostat Menu Item is Not Displayed", true);
    }
}

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

License:Open Source License

/**
 * Click the logout menu item from the menu page.
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickLogoutMenuItem()
 *//*from   w w  w  . j av  a2  s.c  o m*/
@Override
public void clickLogoutMenuItem() {

    WaitUtil.tinyWait();
    getAction().rejectAlert();
    setLogString("Check Logout Menu Item is Displayed", true);
    final boolean state = isDisplayed(getDriver(), By.cssSelector(LOGOUT_MENU_ITEM), TINY_TIMEOUT);
    WaitUtil.tinyWait();
    if (state) {
        setLogString("Logout Menu Item is Clicked", true);
        final WebElement menuIcon = getElement(getDriver(), By.cssSelector(LOGOUT_MENU_ITEM), SHORT_TIMEOUT);
        menuIcon.click();
        WaitUtil.tinyWait();
    } else {
        setLogString("Logout Menu Item is Not Displayed", true);
    }

}