Example usage for org.openqa.selenium By tagName

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

Introduction

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

Prototype

public static By tagName(String tagName) 

Source Link

Usage

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

License:Open Source License

/**
 * Filter criteria.//from  ww  w  .j a  v a2 s .com
 * @param criteriaString the criteria string
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#filterCriteria(java.lang.String)
 */
public void filterCriteria(String criteriaString) {

    isPageLoaded();
    setLogString("Enter criteria to filter." + criteriaString, true);
    isDisplayed(driverManager.getAdminDriver(), By.name(CRITERIA), SHORT_TIMEOUT);
    final WebElement criteriaText = getElement(driverManager.getAdminDriver(), By.name(CRITERIA), TINY_TIMEOUT);
    criteriaText.sendKeys(criteriaString);
    final WebElement searchbutton = getElementBySubElementAttr(driverManager.getAdminDriver(), formElement,
            By.tagName(TAG_INPUT), ATTR_VALUE, SEARCH, SHORT_TIMEOUT);
    searchbutton.click();
    smallWait();
}

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

License:Open Source License

/**
 * Click filtered record.//from ww  w. jav  a 2  s  .com
 * @param recordNumber the record number
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#clickFilteredRecord(int)
 */
@Override
public void clickFilteredRecord(int recordNumber) {

    setLogString("Select the record retrieved for the criteria filtered.", true);
    driverManager.getAdminDriver().switchTo().defaultContent();
    smallWait();
    driverManager.getAdminDriver().switchTo().frame(0);
    final List<WebElement> aElement = getElements(driverManager.getAdminDriver(), By.tagName(TAG_ANCHOR),
            TINY_TIMEOUT);
    aElement.get(0).click();
    smallWait();
}

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

License:Open Source License

/**
 * Gets the required thermostat container.
 * @param thermostat the thermostat/*from   www .java  2s . c o  m*/
 * @return the required thermostat container
 */
private WebElement getRequiredThermostatContainer(final String thermostat) {

    setLogString("Get current temperature for thermostat : " + thermostat, true);
    WebElement thermostatTable = null;
    setLogString("Get thermostats.", true);
    driverManager.getAdminDriver().switchTo().defaultContent();
    smallWait();
    driverManager.getAdminDriver().switchTo().frame(1);
    setLogString("Retrieve the thermostat data from the filtered data.", true);

    final WebElement bodyElement = getElement(driverManager.getAdminDriver(), By.tagName(TAG_BODY),
            TINY_TIMEOUT);
    final List<WebElement> itemTables = getElementsBySubElement(driverManager.getAdminDriver(), bodyElement,
            By.className(ITEM_TABLE), TINY_TIMEOUT);

    for (final WebElement itemTable : itemTables) {
        final List<WebElement> testThermostat = getElementsBySubElementText(driverManager.getAdminDriver(),
                itemTable, By.tagName(TAG_TD), thermostat.trim(), SHORT_TIMEOUT);
        if (testThermostat.size() > ZERO) {
            thermostatTable = itemTable;
            break;
        }
    }
    return thermostatTable;
}

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

License:Open Source License

/**
 * Gets the current temperature.//  w w  w  . j  a va 2  s. c o  m
 * @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.admin.page.impl.AdminHomePageImpl.java

License:Open Source License

/**
 * logout.//from w w  w.j  a v  a 2 s  . c  om
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#logout()
 */
@Override
public void logout() {

    setLogString("Click logout", true);
    driverManager.getAdminDriver().switchTo().defaultContent();
    final WebElement logoutLink = getElementByText(driverManager.getAdminDriver(), By.tagName(TAG_ANCHOR),
            LOGOUT, SHORT_TIMEOUT);
    logoutLink.click();
    tinyWait();
}

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

License:Open Source License

/**
 * Click dialogue link./*from  ww  w  . ja  v a 2 s.  c o m*/
 * @param thermostatName thermostat name
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#clickDiagLink(java.lang.String)
 */
@Override
public void clickDiagLink(String thermostatName) {

    setLogString("Click dialogue link", true);
    final WebElement thermostatTable = getRequiredThermostatContainer(thermostatName);
    setLogString("Click diag link", true);
    final WebElement dialogueElement = getElementBySubElementText(driverManager.getAdminDriver(),
            thermostatTable, By.tagName(TAG_ANCHOR), DIAG, MEDIUM_TIMEOUT);
    dialogueElement.click();
    mediumWait();
}

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

License:Open Source License

/**
 * Gets the picker element.//from  w  ww.j a v  a  2s  .  c o  m
 * @param setAwayParam the set away param
 * @return element.
 * @see com.ecofactor.qa.automation.newapp.page.AwaySettingsUIPage#getPickerElement(com.ecofactor.qa.automation.newapp.enums.SetAwayParams)
 */
@Override
public WebElement getPickerElement(final SetAwayParams setAwayParam) {

    WaitUtil.tinyWait();
    final boolean setAwayPage = setAway.isSetAwayPageLoaded();

    // setAway.clickAwaySettings();
    if (setAwayPage == true) {

        setAway.clickAwaySettings();
    } /* else {
              
      thPageOps.clickSettingsMenu();
      menuPage.clickAwayHiglighted();
      setAway.clickAwaySettings();
      }*/

    final WebElement settingsElement = getElement(getDriver(), By.cssSelector(SETTINGS_CONTAINER),
            TINY_TIMEOUT);

    List<WebElement> selectContainer = getElementsBySubElement(getDriver(), settingsElement,
            By.cssSelector("span.select_container"), TINY_TIMEOUT);

    final WebElement setAwayParamElement = getElementBySubElement(getDriver(),
            selectContainer.get(setAwayParam.getValue()), By.tagName("option"), TINY_TIMEOUT);
    return setAwayParamElement;
}

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

License:Open Source License

/**
 * Checks if is sets the away param label displayed.
 * @param setAwayParam the set away param
 * @return true, if is sets the away param label displayed
 * @see com.ecofactor.qa.automation.newapp.page.AwaySettingsUIPage#isSetAwayParamLabelDisplayed(com.ecofactor.qa.automation.newapp.enums.SetAwayParams)
 *///  ww w  .  j a v a2  s . c  o  m
public boolean isSetAwayParamLabelDisplayed(final SetAwayParams setAwayParam) {

    final WebElement setpointPicker = getElement(getDriver(), By.cssSelector("div.settings_content"),
            TINY_TIMEOUT);
    return getElementBySubElementText(getDriver(), setpointPicker, By.tagName("label"), setAwayParam.toString(),
            TINY_TIMEOUT).isDisplayed();

}

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

License:Open Source License

/**
 * @return//  w w w  . j av  a 2s  .c  o  m
 * @see com.ecofactor.qa.automation.newapp.page.SavingsPage#isSavingsDollarVertical()
 */
@Override
public boolean isSavingsDollarVertical() {

    final WebElement savingsDollarElement = getElement(getDriver(),
            By.className("fusioncharts-yaxis-0-gridlabels"), TINY_TIMEOUT);
    final List<WebElement> savingsDollar = getElementsBySubElement(getDriver(), savingsDollarElement,
            By.tagName("text"), TINY_TIMEOUT);
    boolean isVertical = false;
    for (WebElement webElement : savingsDollar) {
        setLogString("SavingsDollar :"
                + getElementBySubElement(getDriver(), webElement, By.tagName("tspan"), TINY_TIMEOUT).getText(),
                true, CustomLogLevel.HIGH);
        isVertical = Integer.valueOf(webElement.getLocation().getX())
                .equals(Integer.valueOf(savingsDollar.get(1).getLocation().getX()));
        if (!isVertical) {
            break;
        }
    }
    setLogString("SavingsDollar isVertical :" + isVertical, true, CustomLogLevel.LOW);
    return isVertical;
}

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

License:Open Source License

/**
 * @return// www .j a  v  a 2  s. c o  m
 * @see com.ecofactor.qa.automation.newapp.page.SavingsPage#isSavingsMonthHorizontal()
 */
@Override
public boolean isSavingsMonthHorizontal() {

    final WebElement savingsMonthElement = getElement(getDriver(),
            By.className("fusioncharts-xaxis-0-gridlabels"), TINY_TIMEOUT);
    final List<WebElement> savingsMonth = getElementsBySubElement(getDriver(), savingsMonthElement,
            By.tagName("text"), TINY_TIMEOUT);
    boolean isHorizontal = false;
    for (WebElement webElement : savingsMonth) {
        setLogString("SavingsMonth :"
                + getElementBySubElement(getDriver(), webElement, By.tagName("tspan"), TINY_TIMEOUT).getText(),
                true, CustomLogLevel.HIGH);
        isHorizontal = Integer.valueOf(webElement.getLocation().getY())
                .equals(Integer.valueOf(savingsMonth.get(1).getLocation().getY()));
        if (!isHorizontal) {
            break;
        }
    }
    setLogString("SavingsMonth isHorizontal :" + isHorizontal, true, CustomLogLevel.LOW);
    return isHorizontal;
}