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.MenuPageImpl.java

License:Open Source License

/**
 * Click the away temperature menu item from the menu page.
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickAwayTemperature()
 *///from w w  w .ja va2  s  .c  om
@Override
public void clickAwayTemperature() {

    WaitUtil.tinyWait();
    setLogString("Check Away Temperature Menu Item is Displayed", true);
    final boolean state = isDisplayed(getDriver(), By.cssSelector(AWAY_TEMPERATURE_MENU_ITEM), TINY_TIMEOUT);
    if (state) {
        setLogString("Away Temperature Menu Item is Clicked", true);
        getAction().rejectAlert();
        final WebElement menuIcon = getElement(getDriver(), By.cssSelector(AWAY_TEMPERATURE_MENU_ITEM),
                TINY_TIMEOUT);
        // setLogString("log" + menuIcon.getAttribute("class"), true);
        WaitUtil.oneSec();
        menuIcon.click();
        // getAction().click(menuIcon);
        getAction().rejectAlert();
    } else {
        setLogString("Away Temperature Menu Item is Not Displayed", true);
    }
}

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

License:Open Source License

/**
 * Checks if is page loaded./*  ww  w. ja v a2 s . com*/
 * @return true, if is page loaded
 * @see com.ecofactor.qa.automation.mobile.page.BasePage#isPageLoaded()
 */
@Override
public boolean isPageLoaded() {

    setLogString("Verify the Menu Page is loaded", true, CustomLogLevel.MEDIUM);
    return isDisplayed(getDriver(), By.cssSelector(MENU_CONTAINER), TINY_TIMEOUT)
            && isDisplayed(getDriver(), By.cssSelector(THERMOSTAT_MENU_ITEM), TINY_TIMEOUT)
            && isDisplayed(getDriver(), By.cssSelector(AWAY_TEMPERATURE_MENU_ITEM), TINY_TIMEOUT)
            && isDisplayed(getDriver(), By.cssSelector(LOGOUT_MENU_ITEM), TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Swipe page./*from   w ww  . ja  v  a2s .  com*/
 * @param leftOrRight the left or right
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#swipePage(java.lang.String)
 */
@Override
public void swipePage(String leftOrRight) {

    WebElement thermostatContent = null;

    if (leftOrRight.equalsIgnoreCase(RIGHT)) {
        isDisplayed(getDriver(), By.cssSelector(MENU_HEADER), TINY_TIMEOUT);
        thermostatContent = getElement(getDriver(), By.cssSelector(MENU_HEADER), TINY_TIMEOUT);
        WaitUtil.oneSec();
        thermostatContent.click();
        // getAction().doSwipeRight(thermostatContent);

    } else {
        isDisplayed(getDriver(), By.className(MENU_PAGE_ICON), TINY_TIMEOUT);
        thermostatContent = getElement(getDriver(), By.className(MENU_PAGE_ICON), TINY_TIMEOUT);
        getAction().click(thermostatContent);
        getAction().rejectAlert();
    }
}

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

License:Open Source License

/**
 * Checks if is savings label displayed.
 * @return true, if is savings label displayed
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#isSavingsLabelDisplayed()
 */// w  w  w.  j a v a2s  . c  o m
@Override
public boolean isSavingsLabelDisplayed() {

    setLogString("Check Savings label is displayed", true, CustomLogLevel.HIGH);
    return isDisplayed(getDriver(), By.cssSelector(SAVINGS_NAME), TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Click savings./*from w ww  . j av  a 2 s  .  com*/
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickSavings()
 */
@Override
public void clickSavings() {

    setLogString("Click Savings in Menu page", true, CustomLogLevel.HIGH);
    final WebElement savings = getElement(getDriver(), By.cssSelector(SAVINGS_LABEL), TINY_TIMEOUT);
    getAction().click(savings);
}

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

License:Open Source License

/**
 * click thermostat when it highlighted.
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickThermostatHighlighted()
 *//*from   www.  j a  v  a 2 s. c o  m*/
@Override
public void clickThermostatHighlighted() {

    WaitUtil.smallWait();
    setLogString("Check Thermostat Menu Item is Displayed", true);
    isDisplayed(getDriver(), By.cssSelector(THERMOSTAT_HIGHLIGHT), TINY_TIMEOUT);
    // System.out.println(stateEnable + "stateEnable");
    setLogString("Thermostat Menu Item is Clicked", true);
    final WebElement menuIcon = getElement(getDriver(), By.cssSelector(THERMOSTAT_HIGHLIGHT), TINY_TIMEOUT);
    WaitUtil.oneSec();
    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 menu container.// w w  w  .ja v a2  s.  co m
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickMenuContainer()
 */
@Override
public void clickMenuContainer() {

    final WebElement containerEle = getElement(getDriver(), By.cssSelector(MENU_CONTAINER), TINY_TIMEOUT);
    WaitUtil.oneSec();
    containerEle.click();
    getAction().rejectAlert();

}

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

License:Open Source License

/**
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickAwayHiglighted()
 *//*from  w  ww  .  ja  v  a 2s .c o m*/
@Override
public void clickAwayHiglighted() {

    WaitUtil.tinyWait();
    setLogString("Check Away Temperature Menu item Highlighted is Displayed", true);
    final boolean state = isDisplayed(getDriver(), By.cssSelector(AWAY_TEMPERATURE_HIGHLIGHTED), TINY_TIMEOUT);
    if (state) {
        setLogString("Away Temperature Menu Highlighted Item is Clicked", true);
        final WebElement menuIcon = getElement(getDriver(), By.cssSelector(AWAY_TEMPERATURE_HIGHLIGHTED),
                TINY_TIMEOUT);
        WaitUtil.oneSec();
        menuIcon.click();
        // getAction().click(menuIcon);
        getAction().rejectAlert();
    } else {
        setLogString("Away Temperature Menu Item is Not Displayed", true);
    }

}

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

License:Open Source License

/**
 * Checks if is page loaded./*from  w  w  w  . j ava 2 s. c o m*/
 * @return true, if is page loaded
 * @see com.ecofactor.qa.automation.newapp.page.BasePage#isPageLoaded()
 */
@Override
public boolean isPageLoaded() {

    setLogString("Verify the savings Page is loaded", true, CustomLogLevel.LOW);
    return isDisplayed(getDriver(), By.cssSelector(SAVINGS_CONTAINER), TINY_TIMEOUT)
            && isDisplayed(getDriver(), By.className(SAVINGS_DOLLARS), TINY_TIMEOUT)
            && isDisplayed(getDriver(), By.cssSelector(MENU_SAVINGS), TINY_TIMEOUT);

}

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

License:Open Source License

/**
 * Click menu./*from  w w  w  . j av  a 2s  . c  o  m*/
 * @see com.ecofactor.qa.automation.newapp.page.SavingsPage#clickMenu()
 */
@Override
public void clickMenu() {

    setLogString("Click Menu Icon in Savings", true);
    final boolean isMenuDisplayed = isDisplayed(getDriver(), By.cssSelector(MENU_SAVINGS), MEDIUM_TIMEOUT);
    if (isMenuDisplayed) {
        final WebElement menuElement = getElement(getDriver(), By.cssSelector(MENU_SAVINGS), SHORT_TIMEOUT);
        getAction().click(menuElement);
        tinyWait();
        getAction().rejectAlert();
    }
}