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.SavingsPageImpl.java

License:Open Source License

/**
 * Checks if is arrow not displayed.//from   w ww  .  ja v a 2 s . c o m
 * @param arrow the arrow
 * @return true, if is arrow not displayed
 *         com.ecofactor.qa.automation.newapp.page.SavingsPage#isArrowNotDisplayed
 *         (java.lang.String)
 */
@Override
public boolean isArrowNotDisplayed(String arrow) {

    setLogString("Check " + arrow + " Arrow is not displayed", true, CustomLogLevel.HIGH);
    if (arrow.equalsIgnoreCase("Left")) {
        return isDisplayed(getDriver(), By.cssSelector(LEFT_ARROW), TINY_TIMEOUT);
    } else if (arrow.equalsIgnoreCase("Right")) {
        return isDisplayed(getDriver(), By.cssSelector(RIGHT_ARROW), TINY_TIMEOUT);
    }
    return false;
}

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

License:Open Source License

/**
 * Checks if is learn more displayed./*from   w  ww. ja  v a2 s .  c  o  m*/
 * @return true, if is learn more displayed
 * @see com.ecofactor.qa.automation.newapp.page.SavingsPage#isLearnMoreDisplayed()
 */
@Override
public boolean isLearnMoreDisplayed() {

    setLogString("Check if Learn More is displayed", true, CustomLogLevel.HIGH);
    return isDisplayed(getDriver(), By.cssSelector(".help_icon.clickable"), TINY_TIMEOUT);
}

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

License:Open Source License

/**
 * Gets the tstat status message.// w  w w  .j a  v  a2  s.co  m
 * @return the tstat status message
 */
private String getTstatStatusMessage() {

    String thStatusMsg = null;
    WebElement modeDialog = getElement(getDriver(), By.cssSelector(MODEL_DIALOG), TINY_TIMEOUT);
    if (modeDialog.isDisplayed()) {
        WebElement modeMessage = getElementBySubElement(getDriver(), modeDialog, By.className(ERROR_MODEBOX),
                TINY_TIMEOUT);
        thStatusMsg = getElementBySubElement(getDriver(), modeMessage, By.className(MODEL_LABEL), TINY_TIMEOUT)
                .getText();
        setLogString("Location status message:" + thStatusMsg, true, CustomLogLevel.HIGH);
    }
    return thStatusMsg;
}

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

License:Open Source License

/**
 * Checks if is date picker displayed.//  w w  w  . ja  v  a  2s .  com
 * @return true, if is date picker displayed
 */
@Override
public boolean isDatePickerDisplayed() {

    final List<WebElement> dateTimePickers = getElements(getDriver(),
            By.cssSelector("div.setAwayPicker.awayEndDateTimePicker"), TINY_TIMEOUT);

    setLogString("Check if date picker is displayed.", true, CustomLogLevel.MEDIUM);
    return dateTimePickers.get(0).isDisplayed();
}

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

License:Open Source License

/**
 * Gets the end date./*from w  w w  . j a  v a 2s.c  o  m*/
 * @return the end date
 * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#getEndDate()
 */
@Override
public String getEndDate() {

    final List<WebElement> dateTimePickers = getElements(getDriver(),
            By.cssSelector("div.setAwayPicker.awayEndDateTimePicker"), TINY_TIMEOUT);

    setLogString("Check if date picker is displayed.", true, CustomLogLevel.MEDIUM);
    return dateTimePickers.get(0).getText();
}

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

License:Open Source License

/**
 * Checks if is time picker displayed./*from  w  ww.  ja  v a 2 s .  c  om*/
 * @return true, if is time picker displayed
 */
@Override
public boolean isTimePickerDisplayed() {

    final List<WebElement> dateTimePickers = getElements(getDriver(),
            By.cssSelector("div.setAwayPicker.awayEndDateTimePicker"), TINY_TIMEOUT);

    setLogString("Check if time picker is displayed.", true, CustomLogLevel.MEDIUM);
    return dateTimePickers.get(1).isDisplayed();
}

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

License:Open Source License

/**
 * Gets the end time.//from w ww  .  j av  a 2s .  c o m
 * @return the end time
 * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#getEndTime()
 */
@Override
public String getEndTime() {

    final List<WebElement> dateTimePickers = getElements(getDriver(),
            By.cssSelector("div.setAwayPicker.awayEndDateTimePicker"), TINY_TIMEOUT);

    setLogString("Check if time picker is displayed.", true, CustomLogLevel.MEDIUM);
    return dateTimePickers.get(1).getText();
}

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

License:Open Source License

/**
 * Click close toast error.//from  www. j  a va  2  s.c o  m
 * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#clickCloseToastError()
 */
@Override
public void clickCloseToastError() {

    setLogString("Close Away Toast Error by Clicking on 'X'.", true, CustomLogLevel.MEDIUM);
    final WebElement closeToastErrBtn = getElementBySubElement(getDriver(), getCurrentThermostatContainer(),
            By.cssSelector(CLOSE_TOAST_BTN), ATOMIC_TIMEOUT);
    getAction().click(closeToastErrBtn);
}

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

License:Open Source License

/**
 * Checks whether the Away Date is valid or not.
 * @return the validity status of Away Date
 * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#isDateValidForAway
 *//*from   ww w  .j a va2  s. co  m*/
@Override
public boolean isDateValidForAway() {

    Date currentDate = null;
    Date newDate = null;

    final WebElement dateTimePickerButton = getElement(getDriver(),
            By.cssSelector(".setAwayPicker.awayEndDateTimePicker"), TINY_TIMEOUT);

    String currentDateString = dateTimePickerButton.getText();
    currentDateString = currentDateString.substring(currentDateString.indexOf("-") + 2);

    try {
        currentDate = new SimpleDateFormat("MMM dd, yyyy").parse(currentDateString);
    } catch (Exception ex) {
        setLogString("Exception:" + ex, true);
    }

    setLogString("Value:" + currentDate, true);
    dateTimePickerButton.click();

    setLogString("Set Date Scroll Control Displayed:"
            + isDisplayed(getDriver(), By.cssSelector("a.dwb-e.dwwb.dwwbm"), TINY_TIMEOUT), true);

    setLogString("Trying to set a past date for Away", true);
    final WebElement dateScroll = getElement(getDriver(), By.cssSelector(".dwwl1 > a:nth-child(2)"),
            TINY_TIMEOUT);
    dateScroll.click();

    WaitUtil.tinyWait();

    setLogString("Set the New Date Value", true);
    final WebElement setElement = getElement(getDriver(), By.cssSelector("a.dwb.dwb0.dwb-e"), TINY_TIMEOUT);
    getAction().click(setElement);

    String newDateString = dateTimePickerButton.getText();
    newDateString = newDateString.substring(newDateString.indexOf("-") + 2);

    WaitUtil.tinyWait();

    try {
        newDate = new SimpleDateFormat("MMM dd, yyyy").parse(newDateString);
    } catch (Exception ex) {
        setLogString("Exception:" + ex, true);
    }

    setLogString("New Value:" + newDate, true);

    if (currentDate.compareTo(newDate) < 0 || currentDate.compareTo(newDate) == 0) {
        return true;
    } else {
        return false;
    }
}

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

License:Open Source License

/**
 * Set Away After waiting for 5 minutes idle.
 * @return boolean status of Set Away//  ww w . j ava  2s.co m
 */
@Override
public boolean waitAndSetAway() {

    setLogString("Waiting for 5 minutes", true);
    WaitUtil.waitUntil(300000);

    setLogString("Set Away after 5 minutes wait", true);
    final WebElement setButton = getElement(getDriver(), By.cssSelector("input.ctaButton:nth-child(2)"),
            SHORT_TIMEOUT);
    getAction().click(setButton);
    getAction().rejectAlert();
    setLogString("Toast Display:"
            + isDisplayed(getDriver(), By.cssSelector("div.view_toast_container"), TINY_TIMEOUT), true);

    if (isDisplayed(getDriver(), By.cssSelector("div.view_toast_container"), TINY_TIMEOUT))
        return false;
    else
        return true;
}