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

License:Open Source License

/**
 * Click specified email./* ww  w  .ja  v a2  s  .  com*/
 * @param email the email
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#clickSpecifiedEmail(java.lang.String)
 */
public void clickSpecifiedEmail(String email) {

    DriverConfig.setLogString("Click on the emailId as recieved - " + email, true);
    WebElement element = retrieveElementByLinkText(DriverConfig.getDriver(), email, MEDIUM_TIMEOUT);
    element.click();
    tinyWait();
    DriverConfig.setLogString("Verify istalled harware menu is displayed.", true);
    isDisplayedByLinkText(DriverConfig.getDriver(), supportConfig.get(INSTALLED_HARDWARE_MENU), MEDIUM_TIMEOUT);
}

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

License:Open Source License

/**
 * Click pop up cancel./*from  w ww.jav a 2 s  . c om*/
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#clickPopUpCancel()
 */
public void clickPopUpCancel() {

    DriverConfig.setLogString("Click on the Pop up Cancel.", true);
    List<WebElement> listElement = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), TAG_SPAN,
            ATTR_CLASS, supportConfig.get(OK_BTN));
    for (WebElement element : listElement) {
        if (element.getText().equalsIgnoreCase("Cancel")) {
            element.click();
        }
    }
    smallWait();
}

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

License:Open Source License

/**
 * Click proxy login./* w  w  w.  ja  va 2 s . com*/
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#clickProxyLogin()
 */
@Override
public void clickProxyLogin() {

    DriverConfig.setLogString("Click Proxy Login.", true);
    WebElement element = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_ANCHOR, ATTR_ID,
            supportConfig.get(PROXY_LINK), LONG_TIMEOUT);
    element.click();

}

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

License:Open Source License

/**
 * Iterate results and verify empty fields.
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#iterateResultsAndVerifyEmptyFields()
 *///from   w ww .ja v a2  s .  c o  m
@Override
public void iterateResultsAndVerifyEmptyFields() {

    DriverConfig.setLogString("Iterate Search Results and Verify empty results", true);
    List<WebElement> resultTr = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), "tr", "id",
            "user");
    boolean gateWayModelFound = false;
    String text = "";
    for (WebElement trElement : resultTr) {

        if (gateWayModelFound)
            break;
        List<WebElement> resultTd = trElement.findElements(By.tagName("td"));
        int count = 0;
        for (WebElement tdElement : resultTd) {
            if (count == 9)
                text = tdElement.getText();

            logger.info("Account status: " + text);
            if (text.contains("ACTIVE")) {
                WebElement idElement = resultTd.get(0);
                WebElement searchElement = retrieveElementByLinkText(DriverConfig.getDriver(),
                        idElement.getText(), MEDIUM_TIMEOUT);
                logger.info("click active account.", true);
                searchElement.click();
                WaitUtil.waitUntil(200);

                DriverConfig.setLogString("click Installed Hardware.", true);
                retrieveElementByLinkText(DriverConfig.getDriver(), "Installed Hardware", MEDIUM_TIMEOUT)
                        .click();
                WaitUtil.waitUntil(200);

                WebElement gateWayDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV,
                        ATTR_ID, "supportPage-gatewayDetails", MEDIUM_TIMEOUT);
                DriverConfig.setLogString("click Expand Gateway." + gateWayDiv.getTagName(), true);

                retrieveElementByAttributeValueContainsForSubElement(DriverConfig.getDriver(), gateWayDiv,
                        TAG_IMG, ATTR_CLASS, "show", MEDIUM_TIMEOUT).click();
                WaitUtil.waitUntil(200);

                DriverConfig.setLogString("Verify Gateway model.", true);
                List<WebElement> elementTD = retrieveElementsByTagText(DriverConfig.getDriver(), TAG_TD,
                        "iControl Android Touchscreen");

                for (WebElement element : elementTD) {
                    DriverConfig.setLogString("element.getText() " + element.getText(), true);
                    gateWayModelFound = true;
                    break;
                }
                break;
            }
            count++;
        }
    }
    DriverConfig.setLogString("Check if gateway model 'iControl Android Touchscreen' found.", true);
    Assert.assertTrue(gateWayModelFound, "Gateway model 'iControl Android Touchscreen' not found.");
}

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

License:Open Source License

/**
 * Click energy efficiency check box.//from  w w  w . j  a va2  s  .  com
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#clickEnergyEfficiencyCheckBox()
 */
public void clickEnergyEfficiencyCheckBox() {

    DriverConfig.setLogString("click 'Energy efficiency' check box.", true);
    WebElement element = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID,
            supportConfig.get(ENERGY_EFF_CHECK), MEDIUM_TIMEOUT);
    element.click();
    tinyWait();

    WebElement spanElement = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_SPAN, ATTR_ID,
            "EEText", MEDIUM_TIMEOUT);
    logger.info("Current EE is -" + spanElement.getText());
    if (element.getAttribute("checked") != null) {
        Assert.assertTrue(spanElement.getText().equalsIgnoreCase("ON"));
    } else {
        Assert.assertTrue(spanElement.getText().equalsIgnoreCase("OFF"));
    }
}

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

License:Open Source License

/**
 * Login consumer portal.//from w  w w. j  a  va  2 s .com
 * @param userId the user id
 * @param password the password
 */
public void loginConsumerPortal(String userId, String password) {

    // enter the login credentials
    DriverConfig.setLogString("Check username and password fields", true);
    WebElement userField = DriverConfig.getDriver().findElement(By.id(loginConfig.get(CONSUMER_USER_ID)));
    WebElement passwordField = DriverConfig.getDriver().findElement(By.id(loginConfig.get(CONSUMER_PASSWORD)));
    assertNotNull(userField, "User name field is not available");
    assertNotNull(passwordField, "password field is not available");

    DriverConfig.setLogString("Enter username and password (" + userId + "/" + password + ")", true);
    userField.clear();
    passwordField.clear();

    userField.sendKeys(userId);
    passwordField.sendKeys(password);

    DriverConfig.setLogString("Check Login button, ", true);
    WebElement submitBtn = DriverConfig.getDriver().findElement(By.id(loginConfig.get(CONSUMER_SUBMIT_LOGIN)));
    assertNotNull(submitBtn, "Submit button is not available");

    DriverConfig.setLogString("Click the Login button", true);
    submitBtn.click();
}

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

License:Open Source License

/**
 * Do consumerlogout./*from w ww  .  ja v a  2s.co m*/
 */
public void doConsumerlogout() {

    DriverConfig.setLogString("Click Logout link.", true);
    WebElement logoutLink = DriverConfig.getDriver()
            .findElement(By.cssSelector(loginConfig.get(CONSUMER_LOGOUT_LINK)));
    logoutLink.click();

    DriverConfig.setLogString("Check Login Page", true);
    boolean logoDisplayed = isDisplayedByCSS(DriverConfig.getDriver(), loginConfig.get(CONSUMER_LOGIN_LOGO),
            MEDIUM_TIMEOUT);
    assertTrue(logoDisplayed, "logo is not displayed");

}

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

License:Open Source License

/**
 * Enter character to electricity rate./*  ww  w. j ava 2  s . c  o  m*/
 * @param rate the rate
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#enterCharacterToElectricityRate(java.lang.String)
 */
public void enterCharacterToElectricityRate(String rate) {

    DriverConfig.setLogString("Enter Electricity rate as ." + rate, true);
    WebElement electricityRate = DriverConfig.getDriver()
            .findElement(By.id(supportConfig.get(ELECTRICITY_RATE)));
    electricityRate.sendKeys(rate);
    DriverConfig.setLogString("Click ok button", true);
    WebElement btnElement = DriverConfig.getDriver().findElement(By.className(supportConfig.get(OK_BTN)));
    btnElement.click();
}

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

License:Open Source License

/**
 * Enter character to gas rate.//from   ww  w.  java 2 s  . c om
 * @param rate the rate
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#enterCharacterToGasRate(java.lang.String)
 */
@Override
public void enterCharacterToGasRate(String rate) {

    DriverConfig.setLogString("Enter Gas rate as ." + rate, true);
    WebElement electricityRate = DriverConfig.getDriver().findElement(By.id(supportConfig.get(GAS_RATE)));
    electricityRate.sendKeys(rate);
    DriverConfig.setLogString("Click ok button", true);
    WebElement btnElement = DriverConfig.getDriver().findElement(By.className(supportConfig.get(OK_BTN)));
    btnElement.click();
}

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

License:Open Source License

/**
 * Click OK button./*from ww  w .j a  v  a  2 s .  c  o  m*/
 */
public void clickOkBtn() {

    DriverConfig.setLogString("Click ok button", true);
    List<WebElement> listElement = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), TAG_SPAN,
            ATTR_CLASS, supportConfig.get(OK_BTN));
    for (WebElement element : listElement) {
        if (element.getText().equalsIgnoreCase("OK")) {
            element.click();
        }
    }
    smallWait();
}