Example usage for org.openqa.selenium By cssSelector

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

Introduction

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

Prototype

public static By cssSelector(String cssSelector) 

Source Link

Document

Find elements via the driver's underlying W3C Selector engine.

Usage

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

License:Open Source License

/**
 * Checks if is FAQ clickable./*  w  w  w . j  ava  2s.  c om*/
 * @return true, if is FAQ clickable
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#isFAQClickable()
 */
@Override
public boolean isFAQClickable() {

    setLogString("verify User Aggrement Link is Clickable", true, CustomLogLevel.LOW);
    final WebElement faqTab = getElement(getDriver(), By.cssSelector(FAQ_TAB), TINY_TIMEOUT);
    return isClickable(getDriver(), faqTab, TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Click back./*www . j  a  v  a2s .  c  o m*/
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#clickBack()
 */
@Override
public void clickBack() {

    setLogString("Click Back", true, CustomLogLevel.LOW);
    final WebElement backElement = getElement(getDriver(), By.cssSelector(BACK_BUTTON), TINY_TIMEOUT);
    getAction().click(backElement);
}

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

License:Open Source License

/**
 * @return/* w  w  w  . j  av  a2  s .  co m*/
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getCurrentPwdErrorMsg()
 */
@Override
public String getCurrentPwdErrorMsg() {

    final WebElement currentPwdError = getElement(getDriver(), By.cssSelector(CURRENT_PASSWD_ERROR),
            TINY_TIMEOUT);
    setLogString("Current Password Error : " + currentPwdError.getText(), true, CustomLogLevel.LOW);
    return currentPwdError.getText();
}

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

License:Open Source License

/**
 * @return//from w  w w .  j a v  a 2  s .com
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getInvalidPwdErrorMsg()
 */
@Override
public String getInvalidPwdErrorMsg() {

    final WebElement invalidPwdError = getElement(getDriver(), By.cssSelector(NEW_PASSWD_ERROR), TINY_TIMEOUT);
    setLogString("Invalid Password Error : " + invalidPwdError.getText(), true, CustomLogLevel.LOW);
    return invalidPwdError.getText();
}

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

License:Open Source License

/**
 * @return/*  w  w w. j  a  v  a 2s.  c  o  m*/
 * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#getConfirmPwdErrorMsg()
 */
@Override
public String getConfirmPwdErrorMsg() {

    final WebElement repeatPwdError = getElement(getDriver(), By.cssSelector(CONFIRM_PASSWD_ERROR),
            TINY_TIMEOUT);
    setLogString("Repeat Password Error : " + repeatPwdError.getText(), true, CustomLogLevel.LOW);
    return repeatPwdError.getText();
}

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

License:Open Source License

/**
 * Gets the URL from phone browser.//from w ww .  j a va  2s. c  o m
 * @param element the element
 * @return the URL from phone browser
 */
private String getURLFromPhoneBrowser(final String element) {

    setLogString("Get URL from phone browser", true, CustomLogLevel.LOW);
    final boolean elementDisplayed = isDisplayed(getDriver(), By.cssSelector(element), TINY_TIMEOUT);
    String currentURL = "";
    WebDriverWait wait = new WebDriverWait(getDriver(), 10);
    final WebElement faqElement = getElement(getDriver(), By.cssSelector(element), TINY_TIMEOUT);
    if (elementDisplayed == true) {
        final String previousUrl = getDriver().getCurrentUrl();
        faqElement.click();
        getDriver().manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        ExpectedCondition<Boolean> e = new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {

                return (d.getCurrentUrl() != previousUrl);
            }
        };
        wait.until(e);
        currentURL = getDriver().getCurrentUrl();

    }
    return currentURL;
}

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

License:Open Source License

/**
 * Click Savings Energy Efficient Link./*from   w w  w. j a v a2 s  .com*/
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatPageOps#clickSavingsEELink()
 */
@Override
public void clickSavingsEELink() {

    setLogString("Click Savings EE Link", true, CustomLogLevel.LOW);
    final WebElement savingsEELink = getElement(getDriver(), By.cssSelector(SAVINGS_ENERGY), THREE_SEC);
    savingsEELink.click();
    WaitUtil.oneSec();
    //getAction().rejectAlert();
}

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

License:Open Source License

/**
 * Click current temp.//  w  w  w  .  j ava 2 s  .  c  o  m
 * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#clickCurrentTemp()
 */
@Override
public void clickCurrentTemp() {

    setLogString("Click CurrentTemperature", true, CustomLogLevel.LOW);
    isDisplayedBySubElement(getDriver(), getCurrentThermostatContainer(), By.cssSelector(CURRENT_TEMPERATURE),
            ATOMIC_TIMEOUT);
    final WebElement currentTemperature = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.className(CURRENT_TEMPERATURE), ATOMIC_TIMEOUT);

    final boolean isClickable = isClickable(getDriver(), currentTemperature, TINY_TIMEOUT);
    if (isClickable) {
        setLogString("Clicked CurrentTemperature", true, CustomLogLevel.LOW);
        try {
            getAction().click(currentTemperature);
            getAction().rejectAlert();
        } catch (WebDriverException wde) {
            setLogString("Cannot Click CurrentTemperature", true, CustomLogLevel.LOW);
        }
    } else {
        setLogString("Cannot Click Current Temperature", true, CustomLogLevel.LOW);
    }

}

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

License:Open Source License

/**
 * Sets the away popup closing./*from w  ww.j  av a  2 s  .co  m*/
 * @see com.ecofactor.qa.automation.newapp.page.ThermostatPage#setAway()
 */
@Override
public void setAway() {

    loadAwaySettingsPopup();

    final WebElement footerElement = getElement(getDriver(), By.cssSelector(".footerAwayPicker"),
            SHORT_TIMEOUT);
    final WebElement awaySettingsPopUp = getElementBySubElement(getDriver(), footerElement,
            By.cssSelector(".ctaButton.setAwaySubmitButton"), SHORT_TIMEOUT);
    awaySettingsPopUp.click();
    // getAction().click(awaySettingsPopUp);
    getAction().rejectAlert();
    if (awaySettingsPopUp != null) {
        // getAction().click(awaySettingsPopUp);
        awaySettingsPopUp.click();
        WaitUtil.oneSec();
        getAction().rejectAlert();
    }
}

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

License:Open Source License

/**
 * Load away settings popup./*from  w  w w .j a v a2  s.  co  m*/
 * @return true, if successful
 */
@Override
public boolean loadAwaySettingsPopup() {

    setLogString("Check whether set away popup is already opened", true);
    if (isDisplayed(getDriver(), By.cssSelector("input.ctaButton.setAwayCancelButton"), TINY_TIMEOUT)) {
        setLogString("Away settings popup already open. Closing the popup", true);
        final WebElement cancelButton = getElement(getDriver(),
                By.cssSelector(".ctaButton.setAwayCancelButton"), TINY_TIMEOUT);
        getAction().click(cancelButton);
        getAction().rejectAlert();
    }

    clickSetAway();
    return thPageUI.isAwaySettingsPopUpLoaded();
}