Example usage for org.openqa.selenium WebElement getAttribute

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

Introduction

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

Prototype

String getAttribute(String name);

Source Link

Document

Get the value of the given attribute of the element.

Usage

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

License:Open Source License

/**
 * Checks if is account tab highlighted.
 * @return true, if is account tab highlighted
 * @see com.ecofactor.qa.automation.insite.page.PartnerManagement#isAccountTabHighlighted()
 *///from   w  ww.  ja  v  a  2 s .c  om
@Override
public boolean isAccountTabHighlighted() {

    LogUtil.setLogString("Check Primary Account Details tab Highlighted ", true);
    final WebElement accountTab = DriverConfig.getDriver().findElement(By.id(MENU_ACCOUNT_TAB));
    return accountTab.getAttribute("class").contains(ACTIVE);
}

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

License:Open Source License

/**
 * Check if is contact tab highlighted.//  w  w  w . j  ava  2  s .  c o m
 * @return true, if is contact tab highlighted.
 * @see com.ecofactor.qa.automation.insite.page.PartnerManagement#isContactTabHighlighted()
 */
@Override
public boolean isContactTabHighlighted() {

    LogUtil.setLogString("Check Contact Information tab Highlighted ", true);
    final WebElement contactTab = DriverConfig.getDriver().findElement(By.id(MENU_CONTACT_TAB));
    return contactTab.getAttribute("class").contains(ACTIVE);
}

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

License:Open Source License

/**
 * check if partner types tab highlighted.
 * @return true, if partnerTypes tab highlighted.
 * @see com.ecofactor.qa.automation.insite.page.PartnerManagement#isPartnerTypesTabHighlighted()
 *//*from  w  ww.  ja v a 2  s . c  o m*/
@Override
public boolean isPartnerTypesTabHighlighted() {

    LogUtil.setLogString("Check Partner Types tab Highlighted ", true);
    final WebElement roleTab = DriverConfig.getDriver().findElement(By.id(MENU_ROLE_TAB));
    return roleTab.getAttribute("class").contains(ACTIVE);
}

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

License:Open Source License

/**
 * Checks if is second page displayed./*from www.  ja va2 s .  c o m*/
 * @return true, if is second page displayed
 * @see com.ecofactor.qa.automation.insite.page.PartnerManagement#isSecondPageDisplayed()
 */
@Override
public boolean isSecondPageDisplayed() {

    LogUtil.setLogString("Check either page is in 2nd page", true);
    WaitUtil.smallWait();
    final WebElement firstPage = retrieveElementByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD,
            ATTR_CLASS, "ef_smallLabel", SHORT_TIMEOUT);
    System.out.println(firstPage.getText() + "fsdf" + firstPage.getAttribute("class"));
    return true;
}

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

License:Open Source License

/**
 * Verify permissions mode.//from  ww w . j  av  a2s. c  om
 * @see com.ecofactor.qa.automation.insite.page.RoleManagement#verifyPermissionsMode()
 */
@Override
public void verifyPermissionsMode() {

    DriverConfig.setLogString("Check for Permissions Assigned properly.", true);
    mediumWait();

    final List<WebElement> userRow = DriverConfig.getDriver().findElements(By.xpath(".//*[@id='user']"));

    for (int i = 1; i <= userRow.size(); i++) {

        userRow.get(0).getText();
        final String permissionValue = userRow.get(i - 1).getText();
        DriverConfig.setLogString("Permission : " + permissionValue, true);

        final WebElement element = DriverConfig.getDriver()
                .findElement(By.xpath(".//*[@id='user'][" + i + "]/td[2]/img"));

        if (element.getAttribute("src").contains("https://insite-apps-qa.ecofactor.com/images/ok_icon.png")) {

            DriverConfig.setLogString("Enabled for Read Only", true);
        } else {
            DriverConfig.setLogString("Not assigned for Read", true);
        }

        final WebElement element1 = DriverConfig.getDriver()
                .findElement(By.xpath(".//*[@id='user'][" + i + "]/td[3]/img"));

        if (element1.getAttribute("src").contains("https://insite-apps-qa.ecofactor.com/images/ok_icon.png")) {

            DriverConfig.setLogString("Enabled for Write Only", true);
        } else {
            DriverConfig.setLogString("Not assigned for Write", true);
        }
        final WebElement element2 = DriverConfig.getDriver()
                .findElement(By.xpath(".//*[@id='user'][" + i + "]/td[4]/img"));

        if (element2.getAttribute("src").contains("https://insite-apps-qa.ecofactor.com/images/ok_icon.png")) {

            DriverConfig.setLogString("Enabled for Delete Only", true);
        } else {
            DriverConfig.setLogString("Not assigned for Delete", true);
        }

    }

}

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

License:Open Source License

/**
 * @return//from  w w  w.  ja v a2  s .c  o  m
 * @see com.ecofactor.qa.automation.insite.page.RoleManagement#getResult()
 */
@Override
public String getResult() {

    WebElement resultText = retrieveElementById(DriverConfig.getDriver(), "algo-job-output");
    DriverConfig.setLogString("Result : " + resultText.getAttribute(ATTR_VALUE), true);
    return resultText.getAttribute(ATTR_VALUE);
}

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

License:Open Source License

/**
 * Verify and log thermostat details.// ww w.  j  a v a 2  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 reset password.//  ww  w  . java2s . c o m
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#clickResetPassword()
 */
public void clickResetPassword() {

    smallWait();
    DriverConfig.setLogString("click reset password.", true);
    WebElement resetPswdDiv = DriverConfig.getDriver()
            .findElement(By.id("supportPage-leftNavigation-resetPasswordLink"));
    logger.info("resetPswdDiv class: " + resetPswdDiv.getAttribute("class"));
    resetPswdDiv.click();
    smallWait();
    List<WebElement> okButton = DriverConfig.getDriver().findElements(By.tagName("button"));
    okButton.get(0).click();
    closeAlert(DriverConfig.getDriver());
}

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

License:Open Source License

/**
 * Iterate results and verify comcast id.
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#iterateResultsAndVerifyComcastId()
 */// w  ww  . j ava 2 s  .  co m
@Override
public void iterateResultsAndVerifyComcastId() {

    DriverConfig.setLogString("Iterate Search Results and verify ComcastId", true);
    List<WebElement> resultTr = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), "tr", "id",
            "user");
    for (WebElement trElement : resultTr) {
        logger.info("tr id: " + trElement.getAttribute("id"));
        List<WebElement> resultTd = trElement.findElements(By.tagName("td"));
        int i = 0;
        for (WebElement td : resultTd) {
            if (i == 0) {
                Assert.assertFalse(td.getText().isEmpty(), "Search result is empty");
            }
            i++;
        }
    }
}

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

License:Open Source License

/**
 * Click energy efficiency check box./*w  w w .j  a  va2s . c  o  m*/
 * @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"));
    }
}