Example usage for org.openqa.selenium By className

List of usage examples for org.openqa.selenium By className

Introduction

In this page you can find the example usage for org.openqa.selenium By className.

Prototype

public static By className(String className) 

Source Link

Document

Find elements based on the value of the "class" attribute.

Usage

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

License:Open Source License

/**
 * Verify welcome text.//from   w  w w . j ava  2  s.  com
 * @param userId the user id
 * @see com.ecofactor.qa.automation.insite.page.InsiteAuthenticatedPage#verifyWelcomeText(java.lang.String)
 */
@Override
public void verifyWelcomeText(String userId) {

    DriverConfig.setLogString("check if welcome text displayed.", true);
    WebElement userInfo = DriverConfig.getDriver().findElement(By.className(insiteConfig.get(EF_SMALL_LABEL)));
    Assert.assertTrue(userInfo.getText().equalsIgnoreCase(userId), "Welcome text doesn't contain the user");

}

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

License:Open Source License

/**
 * <p>//  w w  w  .  j  av  a  2  s .c om
 * Verify the Search is populated with the value included in the textField.
 * </p>
 * @param driver the driver
 * @param searchResultValue the search result value
 * @return boolean
 */
private boolean confirmSearchResultValue(final WebDriver driver, final String searchResultValue) {

    DriverConfig.setLogString("Confirm Serach result as " + searchResultValue, true);
    boolean outcome = false;
    DriverConfig.setLogString("check if multiple results are displayed.", true);
    isMultipleClassNameDisplayed(driver, roleConfig.get(SEARCH_RESULT_CLASS), MEDIUM_TIMEOUT);

    final List<WebElement> resultElements = driver
            .findElements(By.className(roleConfig.get(SEARCH_RESULT_CLASS)));
    DriverConfig.setLogString("check if results displayed are relevent to provided search value.", true);
    for (final WebElement webElement : resultElements) {
        outcome = webElement.getText().contains(searchResultValue) ? true : false;
        DriverConfig.setLogString("Displayed Result." + searchResultValue, true);
        if (outcome) {
            return outcome;
        }
    }
    DriverConfig.setLogString("check if results are displayed.", true);
    Assert.assertEquals(true, resultElements.size() > 0, "Result size is zero");
    return outcome;
}

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

License:Open Source License

/**
 * Check ecp.//from w  ww .  j av a  2 s  .com
 * @return true, if successful
 * @see com.ecofactor.qa.automation.insite.page.RoleManagement#checkEcp()
 */
@Override
public boolean checkEcp() {

    DriverConfig.setLogString("Check Ecp.", true);
    boolean isEcp = true;
    List<WebElement> userRow = DriverConfig.getDriver().findElements(By.id("user"));
    for (int i = 0; i < userRow.size(); i++) {
        userRow = DriverConfig.getDriver().findElements(By.id("user"));
        WebElement subElement = retrieveElementByAttributeValueContainsForSubElement(DriverConfig.getDriver(),
                userRow.get(i), TAG_ANCHOR, ATTR_HREF, "javascript", SHORT_TIMEOUT);
        if (subElement != null && !subElement.getText().isEmpty()) {
            subElement.click();
            tinyWait();
            WebElement ecpText = DriverConfig.getDriver().findElement(By.id("ecpCore"));
            DriverConfig.setLogString("ECP TEXT : " + ecpText.getText(), true);
            if (!ecpText.getText().contains("199")) {
                isEcp = false;
                break;
            }
            DriverConfig.getDriver().findElement(By.className("subNavOn")).click();
            tinyWait();
            clickFind();
            tinyWait();
        }
    }

    return isEcp;
}

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

License:Open Source License

/**
 * Confirm search result value.//from  w w w .  j a  va  2s. c om
 * @param searchResultValue the search result value
 * @return true, if successful
 */
public boolean confirmSearchResultValue(final String searchResultValue) {

    DriverConfig.setLogString(
            "Verify the search result is displayed and check for required result is populated in the grid.",
            true);
    boolean outcome = false;
    Assert.assertTrue(isMultipleClassNameDisplayed(DriverConfig.getDriver(),
            supportConfig.get(SEARCH_RESULT_CLASS), MEDIUM_TIMEOUT), "No Result Found");
    List<WebElement> resultElements = DriverConfig.getDriver()
            .findElements(By.className(supportConfig.get(SEARCH_RESULT_CLASS)));

    for (WebElement webElement : resultElements) {
        outcome = webElement.getText().contains(searchResultValue) ? true : false;
        DriverConfig.setLogString("Record Displayed." + searchResultValue, true);
        if (outcome)
            return outcome;
    }
    DriverConfig.setLogString("verify if result are displayed.", true);
    Assert.assertEquals(true, resultElements.size() > 0, "Result size is 0");
    return outcome;
}

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

License:Open Source License

/**
 * Verify and log thermostat details./*  w ww.  j ava2 s . co m*/
 */
private void verifyAndLogThermostatDetails() {

    DriverConfig.setLogString("Verify the thermostat device status and Log the details.", true);

    logger.info("Installed Hardware details.");
    List<WebElement> noOfInstalledharwareList = DriverConfig.getDriver().findElements(By.id("user"));
    StringBuffer tableContent = new StringBuffer();
    tableContent.append("<table>");
    tableContent.append("<tr style='font-weight:bold'>");
    tableContent.append("<td>Device");
    tableContent.append("</td>");
    tableContent.append("<td>Name/ID");
    tableContent.append("</td>");
    tableContent.append("<td>Model");
    tableContent.append("</td>");
    tableContent.append("<td>Connectivity");
    tableContent.append("</td>");
    tableContent.append("</tr>");

    for (WebElement webElement : noOfInstalledharwareList) {
        tableContent.append("<tr>");
        List<WebElement> columnList = webElement.findElements(By.className("userinfo"));
        for (WebElement webElement2 : columnList) {
            tableContent.append("<td>");
            tableContent.append(webElement2.getText());
            if (webElement2.getText().isEmpty()) {
                DriverConfig.setLogString("check if thermostat status image is displayed.", true);
                WebElement imageElement = retrieveElementByAttributeValueForSubElement(DriverConfig.getDriver(),
                        webElement2, "img", "src", "images", MEDIUM_TIMEOUT);
                if (imageElement.getAttribute("src").contains("INACTIVE")) {
                    tableContent.append(supportConfig.get(THERMOSTAT_INACTIVE));
                } else {
                    tableContent.append(supportConfig.get(THERMOSTAT_ACTIVE));
                }
            }
            tableContent.append("</td>");
        }
        tableContent.append("</tr>");

    }
    tableContent.append("</table>");
    logger.info(tableContent.toString());
}

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

License:Open Source License

/**
 * Click searched result element./*from  w  w w  . j av  a 2s  .  c  o m*/
 * @param searchResultValue the search result value
 */
public void clickSearchedResultElement(final String searchResultValue) {

    logger.info("find search result container.");
    List<WebElement> resultElements = DriverConfig.getDriver()
            .findElements(By.className(supportConfig.get(SEARCH_RESULT_CLASS)));
    DriverConfig.setLogString("find search result shows up proper result and click it.", true);
    for (WebElement webElement : resultElements) {
        boolean outcome = webElement.getText().contains(searchResultValue) ? true : false;

        if (outcome) {
            webElement.click();
            tinyWait();
            break;
        }

    }
}

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

License:Open Source License

/**
 * Do verify pswd reset by new app login.
 * @param userName the user name//  ww  w.  ja v a 2 s.  c o m
 * @param tempPassword the temp password
 * @param newPassword the new password
 * @param newAppUrl the new app url
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#doVerifyPswdResetByNewAppLogin(java.lang.String,
 *      java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public void doVerifyPswdResetByNewAppLogin(String userName, String tempPassword, String newPassword,
        String newAppUrl) {

    /*
     * WebDriver popup = null; Set<String> windowids =
     * DriverConfig.getDriver().getWindowHandles(); Iterator<String> iter =
     * windowids.iterator(); iter.next();
     * DriverConfig.setLogString("Switch to other window and verify the title", true); popup =
     * DriverConfig.getDriver().switchTo().window((String) iter.next()); smallWait(); iter =
     * windowids.iterator(); if (iter.hasNext()) { checkConsumerNewPasswordTrigger(userName,
     * tempPassword); doConsumerChangePassword(tempPassword, newPassword); doConsumerlogout();
     * loginConsumerPortal(userName, newPassword); doConsumerlogout(); popup.close(); // switch
     * to main window DriverConfig.setLogString("Switch to main window", true);
     * DriverConfig.getDriver().switchTo().window((String) iter.next()); }
     */
    DriverConfig.setLogString("Load URL : " + newAppUrl, true);
    DriverConfig.getDriver().get(newAppUrl);
    mediumWait();
    DriverConfig.setLogString("Enter UserName and Password", true);
    clearAndInput(DriverConfig.getDriver(), By.name("username"), userName);
    clearAndInput(DriverConfig.getDriver(), By.name("password"), tempPassword);
    tinyWait();
    DriverConfig.setLogString("Click Login", true);
    DriverConfig.getDriver().findElement(By.className("login_submit")).click();
    largeWait();
    DriverConfig.setLogString("Enter temporary Password : " + tempPassword, true);
    clearAndInput(DriverConfig.getDriver(), By.className("input_old_password"), tempPassword);
    tinyWait();
    DriverConfig.setLogString("Enter New Password : " + newPassword, true);
    clearAndInput(DriverConfig.getDriver(), By.className("input_new_password"), newPassword);
    tinyWait();
    DriverConfig.setLogString("Re-Enter New Password : " + newPassword, true);
    clearAndInput(DriverConfig.getDriver(), By.className("input_confirm_new_password"), newPassword);
    tinyWait();
    DriverConfig.setLogString("Click Continue", true);
    DriverConfig.getDriver().findElement(By.className("continueButton")).click();
    smallWait();
    DriverConfig.setLogString("Check HelpOverlay Page displayed", true);
    isDisplayedByClassName(DriverConfig.getDriver(), "help_slide", SHORT_TIMEOUT);
    while (!isDisplayedByClassName(DriverConfig.getDriver(), "close_ftux_button", SHORT_TIMEOUT)) {
        DriverConfig.setLogString("Click Next.", true);
        DriverConfig.getDriver().findElement(By.className("slick-next")).click();
    }
    DriverConfig.setLogString("Click GetStarted", true);
    DriverConfig.getDriver().findElement(By.className("close_ftux_button")).click();
    tinyWait();
    DriverConfig.setLogString("Click Logout", true);
    DriverConfig.getDriver().findElement(By.cssSelector("div.menu_row.logout")).click();
    assertTrue(isDisplayedByClassName(DriverConfig.getDriver(), "login_submit", SHORT_TIMEOUT),
            "Login Page Not Loaded Successfully");

}

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

License:Open Source License

/**
 * Enter character to electricity rate.//  www  . ja v  a 2s .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.//  w  w  w  . j  a  va  2s  . c o  m
 * @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.UserManagementImpl.java

License:Open Source License

/**
 * Verify account details./*from  www .j  a  v  a 2  s.c  o m*/
 * @see com.ecofactor.qa.automation.insite.page.UserManagement#verifyAccountDetails()
 */
public void verifyAccountDetails() {

    DriverConfig.setLogString("Verify account details.", true);
    final List<WebElement> filterLabelClass = DriverConfig.getDriver()
            .findElements(By.className("filterLabel"));
    final List<WebElement> filterInputClass = DriverConfig.getDriver()
            .findElements(By.className("filterInput"));
    WebElement filterInput = null;
    int loopVal = 0;
    final List<String> accountFieldList = getAcountFieldList();
    for (final WebElement filterLabel : filterLabelClass) {
        filterInput = filterInputClass.get(loopVal);
        final String labelText = filterLabel.getText();
        final String inputText = filterInput.getText();
        if (accountFieldList.contains(labelText)) {
            logger.info("Label Name : " + labelText);
            logger.info("Input Name : " + inputText);
            assertTrue(inputText != null && !inputText.isEmpty(), "Input name is not available");
        }
        loopVal++;
    }
}