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.admin.page.impl.AdminDialoguePageImpl.java

License:Open Source License

/**
 * click clear button//from w  w  w.  j a v a2  s.co m
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminDialoguePage#clickClearBtn()
 */
@Override
public void clickClearBtn() {

    setLogString("Click clear results", true);
    final WebElement readElement = getElement(popup, By.id(CLEAR_BTN), TINY_TIMEOUT);
    readElement.click();
    smallWait();

}

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

License:Open Source License

/**
 * Converted temp value./*from w  w w  .  j av  a2s .c om*/
 * @param fieldValue the field value
 * @param sourceField the source field
 * @param convertButton the convert button
 * @param destinationField the destination field
 * @return the string
 */
private String convertedTempValue(final String fieldValue, final String sourceField, final String convertButton,
        final String destinationField) {

    isDisplayed(popup, By.id(sourceField), SHORT_TIMEOUT);
    clearAndInput(popup, By.id(sourceField), fieldValue);
    final WebElement conversionBtn = getElement(popup, By.id(convertButton), SHORT_TIMEOUT);
    conversionBtn.click();
    final JavascriptExecutor jsExecutor = (JavascriptExecutor) popup;
    final Object val = jsExecutor
            .executeScript("return window.document.getElementById('" + destinationField + "').value;");
    return val.toString();
}

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

License:Open Source License

/**
 * Filter criteria.//from   w ww . j ava2s. c  o m
 * @param criteriaString the criteria string
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#filterCriteria(java.lang.String)
 */
public void filterCriteria(String criteriaString) {

    isPageLoaded();
    setLogString("Enter criteria to filter." + criteriaString, true);
    isDisplayed(driverManager.getAdminDriver(), By.name(CRITERIA), SHORT_TIMEOUT);
    final WebElement criteriaText = getElement(driverManager.getAdminDriver(), By.name(CRITERIA), TINY_TIMEOUT);
    criteriaText.sendKeys(criteriaString);
    final WebElement searchbutton = getElementBySubElementAttr(driverManager.getAdminDriver(), formElement,
            By.tagName(TAG_INPUT), ATTR_VALUE, SEARCH, SHORT_TIMEOUT);
    searchbutton.click();
    smallWait();
}

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

License:Open Source License

/**
 * Gets the current temperature.//  www. ja  v  a2s . c o m
 * @param thermostatName thermostat name
 * @return the current temperature
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#getCurrentTemperature(java.lang.String)
 */
@Override
public String getCurrentTemperature(String thermostatName) {

    final WebElement thermostatTable = getRequiredThermostatContainer(thermostatName);

    setLogString("Fetch current temperature.", true);
    final WebElement fetchTemperature = getElementBySubElementAttr(driverManager.getAdminDriver(),
            thermostatTable, By.tagName(TAG_INPUT), ATTR_VALUE, FETCH, MEDIUM_TIMEOUT);
    mediumWait();
    fetchTemperature.click();
    mediumWait();
    setLogString("Fetch clicked!", true);
    smallWait();
    final WebElement bodyElement = getElement(driverManager.getAdminDriver(), By.tagName(TAG_BODY),
            TINY_TIMEOUT);
    final WebElement tempElement = getElementBySubElement(driverManager.getAdminDriver(), bodyElement,
            By.id(RUNNING_DIAG_TEXT), TINY_TIMEOUT);
    String temperature = tempElement.getText();
    setLogString("Current temperature from admin tool: " + tempElement.getText(), true);
    temperature = temperature.substring(temperature.indexOf(": ", 0) + 1, temperature.indexOf(" ("))
            .replaceAll("F", "").replaceAll("C", "");
    setLogString("Close the fetch", true);
    final WebElement runningBodyElement = getElementBySubElement(driverManager.getAdminDriver(), bodyElement,
            By.id(RUNNING_DIAG_BODY), TINY_TIMEOUT);
    getElementBySubElement(driverManager.getAdminDriver(), runningBodyElement, By.tagName(TAG_INPUT),
            TINY_TIMEOUT).click();
    smallWait();
    return temperature.trim();
}

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

License:Open Source License

/**
 * logout./* www . ja  v  a2 s. c o  m*/
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#logout()
 */
@Override
public void logout() {

    setLogString("Click logout", true);
    driverManager.getAdminDriver().switchTo().defaultContent();
    final WebElement logoutLink = getElementByText(driverManager.getAdminDriver(), By.tagName(TAG_ANCHOR),
            LOGOUT, SHORT_TIMEOUT);
    logoutLink.click();
    tinyWait();
}

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

License:Open Source License

/**
 * Click dialogue link.//  w  ww.j a va  2 s  . c o  m
 * @param thermostatName thermostat name
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#clickDiagLink(java.lang.String)
 */
@Override
public void clickDiagLink(String thermostatName) {

    setLogString("Click dialogue link", true);
    final WebElement thermostatTable = getRequiredThermostatContainer(thermostatName);
    setLogString("Click diag link", true);
    final WebElement dialogueElement = getElementBySubElementText(driverManager.getAdminDriver(),
            thermostatTable, By.tagName(TAG_ANCHOR), DIAG, MEDIUM_TIMEOUT);
    dialogueElement.click();
    mediumWait();
}

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

License:Open Source License

/**
 * login//w w  w  .j av a 2 s  .  com
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminLoginPage#login()
 */
@Override
public void login() {

    loadPage();

    LogUtil.setLogString("Login to Admin Portal Page", true);
    LogUtil.setLogString("Check Username textField is displayed", true);
    clearAndInput(driverManager.getAdminDriver(), By.name(USER_NAME_FIELD), mobileConfig.get(ADMIN_USERNAME));
    LogUtil.setLogString("Enter Username :" + mobileConfig.get(ADMIN_USERNAME), true);

    LogUtil.setLogString("Check Password field is displayed", true);
    clearAndInput(driverManager.getAdminDriver(), By.name(PASSWORD_FIELD), mobileConfig.get(ADMIN_PASSWORD));
    LogUtil.setLogString("Enter Password :" + mobileConfig.get(ADMIN_PASSWORD), true);

    LogUtil.setLogString("Click Continue Button", true);
    isDisplayed(driverManager.getAdminDriver(), By.id(CONTINUE_BTN), TINY_TIMEOUT);
    final WebElement continueBtn = getElement(driverManager.getAdminDriver(), By.id(CONTINUE_BTN),
            TINY_TIMEOUT);
    continueBtn.click();
}

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

License:Open Source License

/**
 * Click menu icon.//from   w ww.j  a  v a  2 s .  c  o  m
 * @see com.ecofactor.qa.automation.newapp.page.AwaySettingsOpsPage#clickMenuIcon()
 */
public void clickMenuIcon() {

    WaitUtil.tinyWait();
    LogUtil.setLogString("Click Menu in away settings", true);
    getAction().rejectAlert();
    final WebElement menuAwayElement = getElement(getDriver(), By.cssSelector(MENU_AWAY), TINY_TIMEOUT);
    WaitUtil.oneSec();
    menuAwayElement.click();
    // getAction().click(menuAwayElement);
    getAction().rejectAlert();
}

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()
 *//*w w w  .j  a  va 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   www.  j  av a 2 s.c  o  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);
    }
}