Example usage for org.openqa.selenium WebElement isEnabled

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

Introduction

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

Prototype

boolean isEnabled();

Source Link

Document

Is the element currently enabled or not?

Usage

From source file:com.digi.selenium.util.common.PageNavigation.java

protected void clickOnRadioRM50() throws InterruptedException {
    // try {/*from   www.  j  ava  2  s .c  om*/
    WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email"));
    System.out.println(emailtxt.isEnabled());
    if (emailtxt.isEnabled()) {
        handleInputField_ByID("reloadForm__email", AppConstants.EMAIL);
        //Thread.sleep(500);
    }
    JavascriptExecutor js1 = (JavascriptExecutor) getDriver();
    js1.executeScript("window.scrollBy(0,400)", "");

    tryToGetElementByXPath("//*[@id='prepaidReloadForm']/ul/li[4]/label/div", 5).click();
    log.info("Success : Radio Button of amonut 30 is clicked");

    tryToGetElementByXPath("//*[@id='prepaidReloadForm']/label/div", 5).click();
    log.info("Success : checkbox is clicked");

    tryToClickElementByXPath("//*[@id='proceedBtn']", 5).click();
    log.info("Success : Proceed Button is clicked");

    waitForPageLoad(100);
    Thread.sleep(500);
    JavascriptExecutor js = (JavascriptExecutor) getDriver();
    js.executeScript("window.scrollBy(0,500)", "");
    /*}catch(Exception e) {
       log.error("Fail : Failed to process reload of amount 30.");
       shutDown();
               
    }*/
}

From source file:com.digi.selenium.util.common.PageNavigation.java

protected void clickOnRadioRM100() throws InterruptedException {
    // try {/*  w  w w.java2  s.  co  m*/
    WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email"));
    System.out.println(emailtxt.isEnabled());
    if (emailtxt.isEnabled()) {
        handleInputField_ByID("reloadForm__email", AppConstants.EMAIL);
        //Thread.sleep(500);
    }
    JavascriptExecutor js1 = (JavascriptExecutor) getDriver();
    js1.executeScript("window.scrollBy(0,400)", "");

    tryToGetElementByXPath("//*[@id='prepaidReloadForm']/ul/li[1]/label/div", 5).click();
    log.info("Success : Radio Button of amonut 100 is clicked");
    tryToGetElementByXPath("//*[@id='prepaidReloadForm']/label/div", 5).click();
    log.info("Success : checkbox is clicked");

    tryToClickElementByXPath("//*[@id='proceedBtn']", 5).click();
    log.info("Success : Proceed Button is clicked");
    /*       
    WebElement proceed=(new WebDriverWait(driver, 1000)).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']")));
    proceed.click();*/
    waitForPageLoad(100);
    Thread.sleep(500);
    JavascriptExecutor js = (JavascriptExecutor) getDriver();
    js.executeScript("window.scrollBy(0,500)", "");
    /*}catch(Exception e) {
       log.error("Fail : Failed to process reload of amount 100.");
       shutDown();
               
    }*/

}

From source file:com.digi.selenium.util.PageNavigation.java

protected void clickOnRadio10() {
    try {// ww  w .j  a  va 2  s  .c  o  m
        // Put email id on text field as it can not be blank
        //*[@id="reloadForm__email"]
        WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email"));
        System.out.println(emailtxt.isEnabled());
        if (emailtxt.isEnabled()) {
            handleInputField_ByID("reloadForm__email", AppConstants.EMAIL);
            Thread.sleep(500);
        }
        JavascriptExecutor js1 = (JavascriptExecutor) getDriver();
        js1.executeScript("window.scrollBy(0,400)", "");
        //*[@id="prepaidReloadForm"]/ul/li[2]/label/div
        WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[2]/label/div"));
        radio.click();
        // now select check box to accept license agreement
        WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div"));
        checkbox.click();
        // click on proceed button after selecting radio button and check box
        // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']"));
        //*[@id="proceedBtn"]
        WebElement proceed = (new WebDriverWait(driver, 1000))
                .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']")));
        proceed.click();
        waitForPageLoad(100);
        Thread.sleep(500);
        JavascriptExecutor js = (JavascriptExecutor) getDriver();
        js.executeScript("window.scrollBy(0,500)", "");
    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        log.error("Fail : Failed to Reload amount.");
        System.exit(0);
    }
}

From source file:com.digi.selenium.util.PageNavigation.java

protected void clickOnRadioRM10() {
    try {//from w  w  w.ja v a2  s  . co m

        // Put email id on text field as it can not be blank
        //*[@id="reloadForm__email"]
        WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email"));
        System.out.println(emailtxt.isEnabled());
        if (emailtxt.isEnabled()) {
            handleInputField_ByID("reloadForm__email", AppConstants.EMAIL);
            Thread.sleep(500);
        }
        JavascriptExecutor js1 = (JavascriptExecutor) getDriver();
        js1.executeScript("window.scrollBy(0,400)", "");
        //*[@id="prepaidReloadForm"]/ul/li[2]/label/div
        WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[2]/label/div"));
        radio.click();
        // now select check box to accept license agreement
        WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div"));
        checkbox.click();
        // click on proceed button after selecting radio button and check box
        // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']"));
        //*[@id="proceedBtn"]
        WebElement proceed = (new WebDriverWait(driver, 1000))
                .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']")));
        proceed.click();
        waitForPageLoad(100);
        Thread.sleep(500);
        JavascriptExecutor js = (JavascriptExecutor) getDriver();
        js.executeScript("window.scrollBy(0,500)", "");
    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        log.error("Fail : Failed to Reload amount.");
        System.exit(0);

    }
}

From source file:com.dukescript.api.selenium.ElementTests.java

License:Open Source License

@Test
public void enabledTest() throws InterruptedException {
    WebElement input = driver.findElement(By.id("input"));
    WebElement button = driver.findElement(By.id("button"));
    Assert.assertEquals(false, button.isEnabled());
    String value = input.getAttribute("value");
    input.sendKeys("Hallo");
    Thread.sleep(500);/*from  w w w .  java2s . co m*/
    Assert.assertEquals(true, button.isEnabled());
}

From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java

License:Open Source License

private boolean isElementOkForInput(WebElement webElement) {

    if (webElement == null) {
        return false;
    }/*from   ww  w.j  a v  a 2s.  c  o  m*/

    if (!webElement.isDisplayed()) {
        return false;
    }

    if (!webElement.isEnabled()) {
        return false;
    }

    return true;
}

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

License:Open Source License

/**
 * Try editing scheduled event./*from   ww w  .ja va2  s. c  om*/
 * 
 * @return true, if successful
 */
public boolean tryEditingScheduledEvent() {

    boolean enabled = false;
    logger.info("check if edit event form is available.", true);
    WebElement newFormElement = DriverConfig.getDriver()
            .findElement(By.id(demandSideManagementConfig.get(EVENT_CREATE_FORM_NAME)));
    if (newFormElement != null) {

        DriverConfig.setLogString("check if edit event is enabled.", true);
        WebElement eventDescElement = retrieveElementByAttributeValueContainsForSubElement(
                DriverConfig.getDriver(), newFormElement, TAG_TEXTAREA, "name",
                demandSideManagementConfig.get(EVENT_DESC), SHORT_TIMEOUT);
        logger.info("Inside editing scheduled event:" + eventDescElement.getText());
        logger.info("Test enabled: " + eventDescElement.isEnabled());
        enabled = eventDescElement.isEnabled();
    }
    return enabled;
}

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

License:Open Source License

/**
 * Gets the next program button./*from  ww  w. ja  v  a  2s . co m*/
 * 
 * @return the next program button
 */
private boolean getNextProgramButton() {

    DriverConfig.setLogString("click next page element.", true);
    boolean nextpageFound = false;
    WebElement paginationBottom = formElement
            .findElement(By.id(demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT)));

    List<WebElement> pageLists = paginationBottom.findElements(By.tagName(TAG_SPAN));

    WebElement nextpage = pageLists.get(8);
    String classDisplayed = nextpage.getAttribute("class");
    logger.info(DISABLED_CLASS + " : nextpage.getAttribute(class): " + classDisplayed, true);
    nextpageFound = classDisplayed.endsWith(demandSideManagementConfig.get(DISABLED_CLASS)) ? true : false;

    if (nextpageFound == false) {
        logger.info(nextpage.isEnabled() + "next page found!");
        nextpage.click();
        DriverConfig.setLogString("next page clicked!", true);
    }
    return !nextpageFound;
}

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

License:Open Source License

/**
 * Wizard 6: Test Thermostat./*from   w ww. j a v  a2s.  c o  m*/
 */
private void checkTestThermostats() {

    DriverConfig.setLogString("Select Wizard 6 : Test Thermostat", true);
    DriverConfig.setLogString("Verify the 'Run Test' button is enabled and Click it.", true);
    isDisplayedById(DriverConfig.getDriver(), "tstatSelect_0", MEDIUM_TIMEOUT);
    isEnabledById(DriverConfig.getDriver(), "runTest", MEDIUM_TIMEOUT);
    DriverConfig.getDriver().findElement(By.id("runTest")).click();

    DriverConfig.setLogString("Verify the PopUp is opened", true);
    isEnabledByClassName(DriverConfig.getDriver(), "boxy-content", MEDIUM_TIMEOUT);

    WebElement boxyContent = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_CLASS,
            "boxy-wrapper fixed");

    if (boxyContent.isEnabled()) {
        DriverConfig.setLogString("Click check box and verify the confirm buton is enabled, and click it.",
                true);
        boxyContent.findElement(By.id("confirmeval")).click();
        smallWait();
        DriverConfig.setLogString("Click check box and verify the Agree buton is enabled, and click it.", true);
        isEnabledByIdSubElement(DriverConfig.getDriver(), boxyContent, "iagree_eval", SHORT_TIMEOUT);
        boxyContent.findElement(By.id("iagree_eval")).click();

        DriverConfig.setLogString("Wait until Selection is displayed in Status Column.", true);
        isDisplayedByTagName(DriverConfig.getDriver(), "select", VERY_LONG_TIMEOUT);

        DriverConfig.setLogString("Select Cool Air", true);
        Select select = new Select(DriverConfig.getDriver().findElement(By.tagName("select")));
        select.selectByVisibleText("Cool Air");
        smallWait();

        DriverConfig.setLogString("Click on Re-Test button and wait until selection is re-Enabled.", true);
        WebElement reTest = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_VALUE,
                "Re-Test");
        reTest.click();
        isDisplayedByTagName(DriverConfig.getDriver(), "select", MEDIUM_TIMEOUT);

        DriverConfig.setLogString("Select Hot Air and wait until selection is re-Enabled.", true);
        Select select2 = new Select(DriverConfig.getDriver().findElement(By.tagName("select")));
        select2.selectByVisibleText("Hot Air");
        isDisplayedByTagName(DriverConfig.getDriver(), "select", MEDIUM_TIMEOUT);

        DriverConfig.setLogString("Select again Cool Air wait until Next bnutton is enabled.", true);
        Select select3 = new Select(DriverConfig.getDriver().findElement(By.tagName("select")));
        select3.selectByVisibleText("Cool Air");
        smallWait();

        DriverConfig.setLogString("Click on Next button", true);
        isEnabledById(DriverConfig.getDriver(), installationConfig.get(NEXT_STEP_BUTTON), MEDIUM_TIMEOUT);
        WebElement nextElement = retrieveElementByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_INPUT,
                ATTR_VALUE, "Next ", MEDIUM_TIMEOUT);
        nextElement.click();
        smallWait();

        DriverConfig.setLogString("Verify the Title message in the 7th Wizard.", true);
        isDisplayedByText(DriverConfig.getDriver(), "titleMsg", "one last thing before", MEDIUM_TIMEOUT);
        DriverConfig.setLogString("Verification Mesage - "
                + DriverConfig.getDriver().findElement(By.id("titleMsg")).getText() + "", true);
        smallWait();
    }
}

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

License:Open Source License

/**
 * Verify consumer login./*from  www.j  a v a 2 s  .  co  m*/
 * @param userId the user id
 */
public void verifyConsumerLogin(String userId) {

    DriverConfig.setLogString("Check logout link is present", true);
    WebElement logoutLink = DriverConfig.getDriver()
            .findElement(By.cssSelector(loginConfig.get(CONSUMER_LOGOUT_LINK)));
    assertTrue(logoutLink.isDisplayed() && logoutLink.isEnabled(), "logout link is not available");

    DriverConfig.setLogString("Check welcome text in header contains " + userId, true);
    WebElement welcomeText = DriverConfig.getDriver()
            .findElement(By.cssSelector(loginConfig.get(CONSUMER_WELCOME_TEXT)));
    assertTrue(welcomeText.getText().contains(userId), "welcome text doesn't contain the user");

    user = userId;
    DriverConfig.setLogString("Login success for " + user, true);

}