Example usage for org.openqa.selenium WebElement click

List of usage examples for org.openqa.selenium WebElement click

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement click.

Prototype

void click();

Source Link

Document

Click this element.

Usage

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  ww.java 2  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);
    }

}

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

License:Open Source License

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

    setLogString("Check Menu Icon is Displayed", true);
    isDisplayed(getDriver(), By.className(MENU_PAGE_ICON), TINY_TIMEOUT);
    setLogString("Click Menu Icon", true);
    final WebElement menuIcon = getElement(getDriver(), By.className(MENU_PAGE_ICON), TINY_TIMEOUT);
    menuIcon.click();
    // getAction().click(menuIcon);
    getAction().rejectAlert();

}

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 ww  .  j  ava2  s .  c  o m
@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

/**
 * Swipe page.//from  www . j  a  v  a 2s. c om
 * @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

/**
 * click thermostat when it highlighted.
 * @see com.ecofactor.qa.automation.newapp.page.MenuPage#clickThermostatHighlighted()
 *//*from w ww.  java2s .  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.// ww  w  .  j  a  va  2  s.c  om
 * @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 w  w .j  a  v  a  2  s . 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.SetAwayPageImpl.java

License:Open Source License

/**
 * Checks whether the Away Date is valid or not.
 * @return the validity status of Away Date
 * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#isDateValidForAway
 *//*from   ww  w . ja va 2  s.co m*/
@Override
public boolean isDateValidForAway() {

    Date currentDate = null;
    Date newDate = null;

    final WebElement dateTimePickerButton = getElement(getDriver(),
            By.cssSelector(".setAwayPicker.awayEndDateTimePicker"), TINY_TIMEOUT);

    String currentDateString = dateTimePickerButton.getText();
    currentDateString = currentDateString.substring(currentDateString.indexOf("-") + 2);

    try {
        currentDate = new SimpleDateFormat("MMM dd, yyyy").parse(currentDateString);
    } catch (Exception ex) {
        setLogString("Exception:" + ex, true);
    }

    setLogString("Value:" + currentDate, true);
    dateTimePickerButton.click();

    setLogString("Set Date Scroll Control Displayed:"
            + isDisplayed(getDriver(), By.cssSelector("a.dwb-e.dwwb.dwwbm"), TINY_TIMEOUT), true);

    setLogString("Trying to set a past date for Away", true);
    final WebElement dateScroll = getElement(getDriver(), By.cssSelector(".dwwl1 > a:nth-child(2)"),
            TINY_TIMEOUT);
    dateScroll.click();

    WaitUtil.tinyWait();

    setLogString("Set the New Date Value", true);
    final WebElement setElement = getElement(getDriver(), By.cssSelector("a.dwb.dwb0.dwb-e"), TINY_TIMEOUT);
    getAction().click(setElement);

    String newDateString = dateTimePickerButton.getText();
    newDateString = newDateString.substring(newDateString.indexOf("-") + 2);

    WaitUtil.tinyWait();

    try {
        newDate = new SimpleDateFormat("MMM dd, yyyy").parse(newDateString);
    } catch (Exception ex) {
        setLogString("Exception:" + ex, true);
    }

    setLogString("New Value:" + newDate, true);

    if (currentDate.compareTo(newDate) < 0 || currentDate.compareTo(newDate) == 0) {
        return true;
    } else {
        return false;
    }
}

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

License:Open Source License

/**
 * Click Set Away from Settigns page./*  w w  w.  j  a va 2  s  .c o  m*/
 * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#clickAwaySettings()
 */
@Override
public void clickAwaySettings() {

    WaitUtil.tinyWait();
    setLogString("Click SetAway in Settings", true, CustomLogLevel.MEDIUM);
    getAction().rejectAlert();
    final WebElement awaySettings = getElement(getDriver(), By.cssSelector(AWAY_SETTINGS), TINY_TIMEOUT);
    WaitUtil.oneSec();
    awaySettings.click();
    getAction().rejectAlert();
}

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

License:Open Source License

/**
 * Click menu settings.//from ww w .j a  v  a2s  .  com
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#clickMenuSettings()
 */
@Override
public void clickMenuSettings() {

    setLogString("Click Accounts settings in Menu Page", true);
    final WebElement menuIcon = getElement(getDriver(), By.cssSelector(SETTINGS_ICON), TINY_TIMEOUT);
    menuIcon.click();
    getAction().rejectAlert();
}