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.insite.page.InsiteInstallationPageImpl.java

License:Open Source License

/**
 * Click role management page./*from w w w.  j av a2 s. c o m*/
 * 
 * @see com.ecofactor.qa.automation.insite.page.InsiteInstallationPage#selectRoleManagementPage()
 */
@Override
public void selectRoleManagementPage() {

    DriverConfig.setLogString("select role management page.", true);
    selectPage(ADMIN);
    smallWait();

    final WebElement subElement = DriverConfig.getDriver().findElement(By.id(insiteConfig.get(SUB_MENU)));
    WebElement rolesLink = retrieveSubElementByTagText(DriverConfig.getDriver(), subElement, TAG_ANCHOR,
            insiteConfig.get(ROLE_MNGMNT), SHORT_TIMEOUT);
    rolesLink.click();
    smallWait();
}

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

License:Open Source License

/**
 * Click logout, and navigate to login page.
 *//*  w w  w . ja  v a  2s  .c o  m*/
public void logout() {

    smallWait();
    logger.info("check if Logout linkis accessible from Insite portal.", true);
    DriverConfig.setLogString("click sign out link.", true);
    WebElement element = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_ANCHOR, ATTR_TITLE,
            "Sign out");
    element.click();
    logger.info("check if logout succeded and login page is displayed.", true);
    boolean logoutSuccess = isDisplayedById(DriverConfig.getDriver(), loginConfig.get(USER_ID), MEDIUM_TIMEOUT);
    Assert.assertTrue(logoutSuccess, "logout failed, USer id text field is not displayed in Login form");
    logger.info("clear the user.", true);
    clearUser();
}

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

License:Open Source License

@Override
public void clickAboutEcofactor() {
    logger.info("check if About Ecofactor link displayed.", true);
    WebElement aboutEcofactorLink = DriverConfig.getDriver()
            .findElement(By.cssSelector(insiteConfig.get(ABOUT_ECOFACTOR_LINK)));
    DriverConfig.setLogString("Click About Ecofactor", true);
    aboutEcofactorLink.click();

}

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

License:Open Source License

/**
 * Check the 1st step Look Up address.// w  ww. j  a  v a 2s  .  c om
 * @param streetAddressValue the street address value
 */
public void checkLookUpAddress(final String streetAddressValue) {

    DriverConfig.setLogString("Select Wizard 1 : LookUp Address", true);
    logger.info("check if street address is displayed.");
    isDisplayedById(DriverConfig.getDriver(), installationConfig.get(STREET_ADDRESS), MEDIUM_TIMEOUT);
    DriverConfig.setLogString("send values to street address." + streetAddressValue, true);
    DriverConfig.getDriver().findElement(By.id("ef_street_address")).sendKeys(streetAddressValue);
    mediumWait();

    DriverConfig.setLogString("Select the top 1st Value from the dropDown.", true);
    WebElement selectedElement = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_LI, ATTR_CLASS,
            installationConfig.get(STREET_DROP_DOWN_CLASS));
    selectedElement.click();
    largeWait();
    DriverConfig.setLogString("check if ok button visible.", true);
    isEnabledById(DriverConfig.getDriver(), installationConfig.get(OK_BUTTON), MEDIUM_TIMEOUT);

    if (DriverConfig.getDriver().findElement(By.id(installationConfig.get(OK_BUTTON))).isEnabled()) {
        DriverConfig.setLogString("Click on View Account", true);
        DriverConfig.getDriver().findElement(By.id(installationConfig.get(OK_BUTTON))).click();
        smallWait();
    }

    DriverConfig.setLogString("Check the HVAC System and Network Availability...", true);
    List<WebElement> networkAvailabilityList = DriverConfig.getDriver()
            .findElements(By.id(installationConfig.get(INTERNET_QUESTION)));
    for (WebElement webElement : networkAvailabilityList) {
        if (webElement.getAttribute(ATTR_VALUE).equalsIgnoreCase("4")) {
            DriverConfig.setLogString("Click on Working Properly..", true);
            webElement.click();
            smallWait();
            break;
        }
    }
    smallWait();
    DriverConfig.setLogString("find and click on Continue button", true);
    isDisplayedById(DriverConfig.getDriver(), installationConfig.get(START_INSTALLATION), MEDIUM_TIMEOUT);
    DriverConfig.getDriver().findElement(By.id(installationConfig.get(START_INSTALLATION))).click();
}

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

License:Open Source License

/**
 * Step 3 : Define HVAC System.//from   www  . java2  s .  co  m
 */
private void checkDefineHVACSystem() {

    DriverConfig.setLogString("Select Wizard 3 :  Define HVAC System", true);
    logger.info("find anything window.");
    isDisplayedByClassName(DriverConfig.getDriver(), installationConfig.get(ANYTHING_WINDOW), MEDIUM_TIMEOUT);

    DriverConfig.setLogString("Verify the done button visibility and click it.", true);
    WebElement doneElement = retrieveElementByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_INPUT,
            ATTR_VALUE, "Done! ", MEDIUM_TIMEOUT);
    doneElement.click();

    DriverConfig.setLogString("Verify the Link Gateway button visibility in HVAC system and click it.", true);
    isEnabledById(DriverConfig.getDriver(), "linkgatewayButton", SHORT_TIMEOUT);
    DriverConfig.getDriver().findElement(By.id("linkgatewayButton")).click();
}

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

License:Open Source License

/**
 * Wizard 6: Test Thermostat./*from  ww  w . j ava2  s  .co m*/
 */
private void checkTestThermostats() {

    DriverConfig.setLogString("Select Wizard 6 : Test Thermostat", true);
    DriverConfig.setLogString("Verify the 'Run Test' button is enabled and Click it.", true);
    isDisplayedById(DriverConfig.getDriver(), "tstatSelect_0", MEDIUM_TIMEOUT);
    isEnabledById(DriverConfig.getDriver(), "runTest", MEDIUM_TIMEOUT);
    DriverConfig.getDriver().findElement(By.id("runTest")).click();

    DriverConfig.setLogString("Verify the PopUp is opened", true);
    isEnabledByClassName(DriverConfig.getDriver(), "boxy-content", MEDIUM_TIMEOUT);

    WebElement boxyContent = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_CLASS,
            "boxy-wrapper fixed");

    if (boxyContent.isEnabled()) {
        DriverConfig.setLogString("Click check box and verify the confirm buton is enabled, and click it.",
                true);
        boxyContent.findElement(By.id("confirmeval")).click();
        smallWait();
        DriverConfig.setLogString("Click check box and verify the Agree buton is enabled, and click it.", true);
        isEnabledByIdSubElement(DriverConfig.getDriver(), boxyContent, "iagree_eval", SHORT_TIMEOUT);
        boxyContent.findElement(By.id("iagree_eval")).click();

        DriverConfig.setLogString("Wait until Selection is displayed in Status Column.", true);
        isDisplayedByTagName(DriverConfig.getDriver(), "select", VERY_LONG_TIMEOUT);

        DriverConfig.setLogString("Select Cool Air", true);
        Select select = new Select(DriverConfig.getDriver().findElement(By.tagName("select")));
        select.selectByVisibleText("Cool Air");
        smallWait();

        DriverConfig.setLogString("Click on Re-Test button and wait until selection is re-Enabled.", true);
        WebElement reTest = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_VALUE,
                "Re-Test");
        reTest.click();
        isDisplayedByTagName(DriverConfig.getDriver(), "select", MEDIUM_TIMEOUT);

        DriverConfig.setLogString("Select Hot Air and wait until selection is re-Enabled.", true);
        Select select2 = new Select(DriverConfig.getDriver().findElement(By.tagName("select")));
        select2.selectByVisibleText("Hot Air");
        isDisplayedByTagName(DriverConfig.getDriver(), "select", MEDIUM_TIMEOUT);

        DriverConfig.setLogString("Select again Cool Air wait until Next bnutton is enabled.", true);
        Select select3 = new Select(DriverConfig.getDriver().findElement(By.tagName("select")));
        select3.selectByVisibleText("Cool Air");
        smallWait();

        DriverConfig.setLogString("Click on Next button", true);
        isEnabledById(DriverConfig.getDriver(), installationConfig.get(NEXT_STEP_BUTTON), MEDIUM_TIMEOUT);
        WebElement nextElement = retrieveElementByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_INPUT,
                ATTR_VALUE, "Next ", MEDIUM_TIMEOUT);
        nextElement.click();
        smallWait();

        DriverConfig.setLogString("Verify the Title message in the 7th Wizard.", true);
        isDisplayedByText(DriverConfig.getDriver(), "titleMsg", "one last thing before", MEDIUM_TIMEOUT);
        DriverConfig.setLogString("Verification Mesage - "
                + DriverConfig.getDriver().findElement(By.id("titleMsg")).getText() + "", true);
        smallWait();
    }
}

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

License:Open Source License

/**
 * Save thermostat name.//from ww w .  j  a va2s . c om
 * @param thermostatName the thermostat name
 * @see com.ecofactor.qa.automation.insite.page.InstallationHardware#saveThermostatName(java.lang.String)
 */
@Override
public void saveThermostatName(String thermostatName) {
    DriverConfig.setLogString("Provide name to existig thermostat.", true);
    smallWait();
    WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID,
            "homeProfile");
    logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class"));
    WebElement hiddenElement = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(),
            tblHomeProfile, "input", "type", "hidden");
    //ForSubElement(driver, tblHomeProfile, TAG_INPUT, "type", "hidden", SHORT_TIMEOUT);
    logger.info("Hidden value: " + hiddenElement.getAttribute("value"));
    String thermostatFld = hiddenElement.getAttribute("value");
    DriverConfig.setLogString("Enter value for thermostat name as " + thermostatName + ".", true);
    WebElement fldThermostatName = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID,
            thermostatFld);
    fldThermostatName.clear();
    fldThermostatName.sendKeys(thermostatName);
    DriverConfig.setLogString("Click link gateway", true);
    WebElement LinkGateWayBtn = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID,
            "nextStepButton");
    LinkGateWayBtn.click();
    smallWait();

}

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

License:Open Source License

@Override
public void addThermostat(String thermostatName) {
    smallWait();//w w w .ja  va  2 s  . co  m
    WebElement getAddressDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV, ATTR_ID,
            "getAddressDiv");
    logger.info("getAddressDiv ID: " + getAddressDiv.getAttribute("id"));

    WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID,
            "homeProfile");
    logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class"));

    List<WebElement> newlyAddedTstats = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(),
            TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats");
    WebElement newlyAddedTstat = newlyAddedTstats.get(newlyAddedTstats.size() - 1);

    logger.info("Newly Added thermostat: " + newlyAddedTstat.getTagName(), true);
    DriverConfig.setLogString("Enter name for existing thermostat field as 'TestTstat'.", true);
    WebElement newTstatName = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(),
            newlyAddedTstat, TAG_INPUT, ATTR_TYPE, "text");
    newTstatName.clear();
    newTstatName.sendKeys("TestTstat");
    tinyWait();

    //click add link
    DriverConfig.setLogString("Click add thermostat link.", true);
    WebElement addThermostatElement = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(),
            getAddressDiv, TAG_ANCHOR, ATTR_ID, "addThermostat");
    addThermostatElement.click();
    tinyWait();

    tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID,
            "homeProfile");
    logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class"), true);

    newlyAddedTstats = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_CLASS,
            "ef_dataTable toCountThermostats");
    newlyAddedTstat = newlyAddedTstats.get(newlyAddedTstats.size() - 1);

    logger.info("newlyAddedTstat: " + newlyAddedTstat.getTagName(), true);
    DriverConfig.setLogString("Enter name for newly added thermostat" + thermostatName + ".", true);
    WebElement newTstatNameFld = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(),
            newlyAddedTstat, TAG_INPUT, ATTR_TYPE, "text");
    newTstatNameFld.sendKeys(thermostatName);
    DriverConfig.setLogString("Click link gateway", true);
    WebElement LinkGateWayBtn = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID,
            "nextStepButton");
    LinkGateWayBtn.click();
    tinyWait();
}

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

License:Open Source License

@Override
public String removeThermostat() {

    smallWait();/*from   ww  w .  j  a  va 2  s.  c  o m*/
    WebElement getAddressDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV, ATTR_ID,
            "getAddressDiv");
    logger.info("remove getAddressDiv ID: " + getAddressDiv.getAttribute("id"), true);

    WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID,
            "homeProfile");
    logger.info("remove tblHomeProfile: " + tblHomeProfile.getAttribute("class"), true);

    //get thermostat name , which will be removed.
    List<WebElement> tagTDElements = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(),
            TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats");
    WebElement tstatTDElement = tagTDElements.get(tagTDElements.size() - 1);

    WebElement lastThermostatNameElement = retrieveElementByAttributeValueByPassingElement(
            DriverConfig.getDriver(), tstatTDElement, TAG_INPUT, ATTR_TYPE, "text");
    String thermostatName = lastThermostatNameElement.getAttribute("value");
    DriverConfig.setLogString("Thermostat to be removed: " + thermostatName, true);

    //select tstat to remove
    DriverConfig.setLogString("Select thermostat to remove.", true);
    smallWait();
    //WebElement selectTstatCheckBox=retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_TYPE, "checkbox", LONG_TIMEOUT);
    WebElement selectTstatCheckBox = DriverConfig.getDriver()
            .findElement(By.cssSelector(installationConfig.get(CHECKBOX)));
    selectTstatCheckBox.click();
    logger.info("CheckBox: " + selectTstatCheckBox.getAttribute("type"), true);

    //click remove link
    DriverConfig.setLogString("Click remove link.", true);
    WebElement removeThermostatLink = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(),
            getAddressDiv, TAG_ANCHOR, ATTR_ID, "delThermostat");
    logger.info("Remove Link id: " + removeThermostatLink.getAttribute("id"), true);
    removeThermostatLink.click();
    smallWait();

    return thermostatName;

}

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

License:Open Source License

/**
 * Click new partner.//  w  w w.  ja v a  2s  . c om
 * @see com.ecofactor.qa.automation.insite.page.PartnerManagement#clickNewPartner()
 */
@Override
public void clickNewPartner() {

    LogUtil.setLogString("Click Create New Partner ", true);
    WaitUtil.smallWait();
    final WebElement createNewUserLink = retrieveElementByLinkText(DriverConfig.getDriver(),
            partnerConfig.get(CREATE_NEW_PARTNER), MEDIUM_TIMEOUT);
    createNewUserLink.click();
}