Example usage for org.openqa.selenium WebElement getText

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

Introduction

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

Prototype

String getText();

Source Link

Document

Get the visible (i.e.

Usage

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

License:Open Source License

/**
 * Gets the menu.//from   ww w.j  a  va  2s .co m
 * @return the menu
 * @see com.ecofactor.qa.automation.insite.page.RoleManagement#getMenu()
 */
@Override
public List<WebElement> getMenu() {

    final List<WebElement> menus = DriverConfig.getDriver().findElements(By.xpath("//*[@id='menu']/li/a"));
    if (menus != null) {
        for (final WebElement webElement : menus) {
            DriverConfig.setLogString("Menu :" + webElement.getText(), true);
        }
    }
    return menus;
}

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

License:Open Source License

/**
 * Gets the role details.//from  w  w  w. j  ava 2 s .c o m
 * @return the role details
 * @see com.ecofactor.qa.automation.insite.page.UserManagement#getRoleDetails()
 */
@Override
public Map<String, String> getRoleDetails() {

    Map<String, String> assignedRole = new HashMap<String, String>();
    DriverConfig.setLogString("Verify role details.", true);
    clickRoleTab();
    tinyWait();

    final List<WebElement> assignedRoles = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(),
            TAG_TD, ATTR_CLASS, "userinfo bgnone");
    int roleLoop = 0;
    for (final WebElement webElement : assignedRoles) {
        if (roleLoop == 0) {
            // DriverConfig.setLogString("Role Name - " + webElement.getText(), true);
            assignedRole.put("Role Name - ", webElement.getText());
        } else {
            // DriverConfig.setLogString("Role Description - " + webElement.getText(), true);
            assignedRole.put("Role Description - ", webElement.getText());
            roleLoop = 0;
        }
        roleLoop++;
    }
    return assignedRole;
}

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

License:Open Source License

/**
 * Gets error message.//from w  ww  . j ava 2  s . c  o m
 * @return Error Message
 */
public String getErrorMessage() {

    DriverConfig.setLogString("Check for error message", true);
    String validationMsg = "";
    final List<WebElement> errorLabels = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), TAG_DIV,
            ATTR_CLASS, "ERROR");
    for (final WebElement webElement : errorLabels) {
        validationMsg += webElement.getText();
    }
    DriverConfig.setLogString("Error message : " + validationMsg, true);
    return validationMsg;
}

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

License:Open Source License

/**
 * <p>/*w ww  .  ja  v a 2  s  .co m*/
 * Send Account details for the New User
 * </p>
 * .
 * @param driver the driver
 * @param firstName the first name
 * @param lastName the last name
 * @param emailAddress the email address
 * @param accountUserName the account user name
 * @param activeUser the active user
 * @param partnerType the partner type
 * @param partner the partner
 */
private void sendAccountDetails(final WebDriver driver, final String firstName, final String lastName,
        final String emailAddress, final String accountUserName, final String activeUser,
        final String partnerType, final String partner) {

    DriverConfig.setLogString("Click on Account Pane and send account details to the required fields.", true);
    logger.info("check accout details tab is displayed.");
    clickAccountDetailsTab();
    isDisplayedById(driver, userConfig.get(FIRST_NAME), MEDIUM_TIMEOUT);
    DriverConfig.setLogString("Enter first name as " + firstName, true);
    driver.findElement(By.id(userConfig.get(FIRST_NAME))).sendKeys(firstName);
    DriverConfig.setLogString("Enter last name as " + lastName, true);
    driver.findElement(By.id(userConfig.get(LAST_NAME))).sendKeys(lastName);
    DriverConfig.setLogString("Enter email address " + emailAddress, true);
    driver.findElement(By.id(userConfig.get(EMAIL_FIELD))).sendKeys(emailAddress);
    DriverConfig.setLogString("Enter user name " + accountUserName, true);
    driver.findElement(By.id(userConfig.get(ACCESS_LOGIN))).sendKeys(accountUserName);
    DriverConfig.setLogString("select user status ", true);
    final Select select1 = new Select(driver.findElement(By.id(userConfig.get(USER_STATUS))));
    select1.selectByVisibleText(activeUser);

    /*
     * Select select2 = new Select(driver.findElement(By.id(userConfig.get(PARTNER_TYPE))));
     * select2.selectByVisibleText(partnerType);
     */
    DriverConfig.setLogString("check partner element displayed.", true);
    final boolean partnerElement = isDisplayedById(driver, userConfig.get(PARTNER_ID), MEDIUM_TIMEOUT);

    (new WebDriverWait(driver, SHORT_TIMEOUT)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            boolean outcome = false;
            outcome = !d.getPageSource().contains(userConfig.get(DEFAULT_PARTNER_ID)) ? true : false;
            return outcome;
        }
    });
    if (!partnerElement) {
        final WebElement partnerText = driver
                .findElement(By.xpath("//td[contains(text(),'Partner')]/following-sibling::td"));
        DriverConfig.setLogString("Default Partner :" + partnerText.getText(), true);
    }
    if (!partner.isEmpty()) {
        final Select select3 = new Select(driver.findElement(By.id(userConfig.get(PARTNER_ID))));
        select3.selectByVisibleText(partner);
    }
}

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

License:Open Source License

/**
 * <p>/*from  www  .  j  a  va  2  s .  c  o m*/
 * Remove all values from the assigned panel to the available panel and verify there is no value
 * in the assigned pane.
 * </p>
 * @param driver the driver
 */
private void removeAllToAvailablePane(final WebDriver driver) {

    DriverConfig.setLogString("Remome all values from the assigned Pane and moving to available pane", true);
    final Select select = new Select(driver.findElement(By.id(userConfig.get(ASSIGNED_ROLES))));

    final List<WebElement> optionsList = select.getOptions();

    for (final WebElement webElement : optionsList) {
        select.selectByVisibleText(webElement.getText());
        driver.findElement(By.id("remove")).click();
    }

    final List<WebElement> optionsList2 = select.getOptions();
    (new WebDriverWait(driver, SHORT_TIMEOUT)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            boolean outcome = false;
            outcome = optionsList2.size() == 0 ? true : false;
            return outcome;
        }
    });
}

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

License:Open Source License

/**
 * Gets the current temperature.//from w w w  .j  a  v  a 2  s  . c  om
 * @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.page.impl.AbstractAuthenticationPageImpl.java

License:Open Source License

/**
 * Gets the toast error message.//from  ww w  .j  a  v  a2 s. co  m
 * @return the toast error message
 * @see com.ecofactor.qa.automation.newapp.page.BasePage#getToastErrorMessage()
 */
public String getToastErrorMessage() {

    tinyWait();
    final WebElement errorElement = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector(ERROR_MESSAGE), TINY_TIMEOUT);
    if (errorElement.isDisplayed()) {
        final String thStatusMsg = errorElement.getText().toString();
        setLogString("Thermostat Toast Error message:" + thStatusMsg, true);
        return thStatusMsg;
    }
    return null;
}

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

License:Open Source License

/**
 * Click location.//from w w w  . ja v  a  2  s. c  o  m
 * @param locationName the location name
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherOpsPage#clickLocation(java.lang.String)
 */
@Override
public void clickLocation(String locationName) {

    List<WebElement> rowList = getElements(getDriver(), By.cssSelector(LOCATION_ROW), SHORT_TIMEOUT);
    for (WebElement webElement : rowList) {
        if (webElement.getText().trim().equalsIgnoreCase(locationName.trim())) {
            getAction().click(webElement);
            getAction().rejectAlert();
            break;
        }
    }
}

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

License:Open Source License

/**
 * Gets the location names.//from  www . j a  v  a 2s. co m
 * @return the location names
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getLocationNames()
 */
@Override
public List<String> getLocationNames() {

    LogUtil.setLogString("Get location names list", true, CustomLogLevel.LOW);
    final WebElement thermostatSwitcherContainer = getElement(getDriver(),
            By.className(THERMOSTAT_SWITCHER_CONTAINER), SHORT_TIMEOUT);
    final List<WebElement> locationElements = getElementsBySubElement(getDriver(), thermostatSwitcherContainer,
            By.className(LOCATION_ROW), SHORT_TIMEOUT);
    final List<String> locNames = new ArrayList<String>();
    for (final WebElement element : locationElements) {
        locNames.add(element.getText());
    }
    return locNames;
}

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

License:Open Source License

/**
 * Gets the tstat name by id.//from  w ww.  ja  va2s .  com
 * @param tstatId the tstat id
 * @return the tstat name by id
 * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getTstatNameById(Integer)
 */
@Override
public String getTstatNameById(final Integer tstatId) {

    LogUtil.setLogString("Get Thermostat Name for tstatId :" + tstatId, true, CustomLogLevel.LOW);
    final WebElement tstatElement = getElementByAttr(getDriver(), By.cssSelector(THERMOSTAT_ROW), THERMOSTAT_ID,
            tstatId.toString(), SHORT_TIMEOUT);
    final WebElement tstatNameElement = getElementBySubElement(getDriver(), tstatElement,
            By.className(THERMOSTAT_NAME), SHORT_TIMEOUT);
    return tstatNameElement.getText();
}