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:io.github.seleniumquery.by.css.pseudoclasses.FocusablePseudoClass.java

License:Apache License

@Override
public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) {
    if (!isVisible(element)) {
        return false;
    }/*from   w  ww .  jav a  2  s .  co m*/
    if (DisabledPseudoClass.DISABLEABLE_TAGS.contains(element.getTagName())) {
        return element.isEnabled();
    }
    if (element.getTagName().equals("a") && element.getAttribute("href") != null) {
        return true;
    }
    //noinspection SimplifiableIfStatement
    if (element.getTagName().equals("area") && element.getAttribute(
            "href") != null /* && inside a named map */ /* && there is a visible image using the map */) {
        return true;
    }
    return element.getAttribute("tabindex") != null;
}

From source file:io.github.seleniumquery.by.firstgen.css.pseudoclasses.DisabledPseudoClass.java

License:Apache License

@Override
public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) {
    // #Cross-Driver
    // When there is a not disabled <option> under a disabled <optgroup>, HtmlUnitDriver considers
    // the <option> to be enabled, when it is not
    if (DriverVersionUtils.getInstance().isHtmlUnitDriver(driver) && OPTION.equals(element.getTagName())) {
        WebElement optionParent = SelectorUtils.parent(element);
        //noinspection ConstantConditions
        if (OPTGROUP.equals(optionParent.getTagName()) && !optionParent.isEnabled()) {
            return true;
        }/*from   w  w w. j  a v  a  2s  .  com*/
    }
    return !element.isEnabled() && DISABLEABLE_TAGS.contains(element.getTagName());
}

From source file:io.github.seleniumquery.by.firstgen.css.pseudoclasses.EnabledPseudoClass.java

License:Apache License

@Override
public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) {
    // #Cross-Driver
    // When there is a not disabled <option> under a disabled <optgroup>, HtmlUnitDriver considers
    // the <option> to be enabled, when it is not
    if (DriverVersionUtils.getInstance().isHtmlUnitDriver(driver) && OPTION_TAG.equals(element.getTagName())) {
        WebElement optionParent = SelectorUtils.parent(element);
        //noinspection ConstantConditions
        if (OPTGROUP_TAG.equals(optionParent.getTagName()) && !optionParent.isEnabled()) {
            return false;
        }//from  w  w  w .  j ava2 s  .c  o m
    }
    return element.isEnabled() && ENABLEABLE_TAGS.contains(element.getTagName());
}

From source file:io.github.seleniumquery.by.firstgen.css.pseudoclasses.FocusablePseudoClass.java

License:Apache License

@Override
public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) {
    if (!isVisible(element)) {
        return false;
    }/*w  w  w  . j  av  a 2s.  c  om*/
    if (DisabledPseudoClass.DISABLEABLE_TAGS.contains(element.getTagName())) {
        return element.isEnabled();
    }
    if ("a".equals(element.getTagName()) && element.getAttribute("href") != null) {
        return true;
    }
    //noinspection SimplifiableIfStatement
    if ("area".equals(element.getTagName()) && element.getAttribute(
            "href") != null /* && inside a named map */ /* && there is a visible image using the map */) {
        return true;
    }
    return element.getAttribute("tabindex") != null;
}

From source file:io.github.seleniumquery.by.firstgen.css.pseudoclasses.PresentPseudoClass.java

License:Apache License

public boolean isPresent(WebElement webElement) {
    try {/*from   ww w .ja v a 2  s . c o m*/
        // calling ANY method forces a staleness check
        webElement.isEnabled();
        // passed staleness check, thus present
        return true;
    } catch (StaleElementReferenceException expected) {
        // failed staleness check, so not present
        return false;
    }
}

From source file:io.github.seleniumquery.functions.jquery.events.ClickFunctionUtils.java

License:Apache License

public static String toString(WebElement element) {
    return "\n\t id attribute: \"" + element.getAttribute("id") + "\"" + "\n\t class attribute: \""
            + element.getAttribute("class") + "\"" + "\n\t name attribute: \"" + element.getAttribute("name")
            + "\"" + "\n\t tag: \"" + element.getTagName() + "\"" + "\n\t text: \"" + element.getText() + "\""
            + "\n\t value attribute: " + element.getAttribute("value") + "\"" + "\n\t size()/dimension: "
            + element.getSize() + "\n\t isDisplayed(): " + element.isDisplayed() + "\n\t isEnabled(): "
            + element.isEnabled() + "\n\t toString(): " + element + "\n";
}

From source file:io.selendroid.nativetests.NativeElementInteractionTest.java

License:Apache License

@Test
public void shouldGetEnbledStateOfElement() {
    openStartActivity();//w  ww  .j ava2 s.  c  om
    WebElement button = driver().findElement(By.id("waitingButtonTest"));
    Assert.assertEquals(button.isEnabled(), true);
}

From source file:io.selendroid.webviewdrivertests.WebElementInteractionTest.java

License:Apache License

@Test
public void shouldGetEnbledStateOfElement() {
    givenWebViewWithFormPageLoaded();/*from   www. j  ava  2s  . com*/

    WebElement element = driver().findElement(By.id("checky"));
    Assert.assertEquals(element.isEnabled(), true);
}

From source file:jhc.redsniff.webdriver.matchers.EnabledElementMatcher.java

License:Apache License

@Override
protected ElementEnabledState stateOf(WebElement item) {
    return item.isEnabled() ? ENABLED : DISABLED;
}

From source file:jhc.redsniff.webdriver.SeleniumController.java

License:Apache License

@Override
public boolean enabled(WebElement element) {
    return element.isEnabled();
}