Java Code Examples for org.openqa.selenium.WebElement.isEnabled()

The following are Jave code examples for showing how to use isEnabled() of the org.openqa.selenium.WebElement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ats-framework   File: RealHtmlCheckBox.java   View Source Code Vote up 6 votes
/**
 * Check the check box
 */
@Override
@PublicAtsApi
public void check() {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement checkBoxElement = RealHtmlElementLocator.findElement(this);
    if (!checkBoxElement.isEnabled()) {
        throw new UnsupportedOperationException("You may not check a disabled element."
                                                + toString());
    }
    if (!checkBoxElement.isSelected()) {
        checkBoxElement.click();
    }

    UiEngineUtilities.sleep();
}
 
Example 2
Project: ats-framework   File: RealHtmlCheckBox.java   View Source Code Vote up 6 votes
/**
 * Uncheck the check box
 */
@Override
@PublicAtsApi
public void unCheck() {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement checkBoxElement = RealHtmlElementLocator.findElement(this);
    if (!checkBoxElement.isEnabled()) {
        throw new UnsupportedOperationException("You may not uncheck a disabled element."
                                                + toString());
    }
    if (checkBoxElement.isSelected()) {
        checkBoxElement.click();
    }

    UiEngineUtilities.sleep();
}
 
Example 3
Project: opentest   File: AssertElementEnabled.java   View Source Code Vote up 6 votes
@Override
public void run() {

    super.run();

    By locator = this.readLocatorArgument("locator");

    this.waitForAsyncCallsToFinish();

    WebElement element = this.getElement(locator);
    if (!element.isEnabled()) {
        throw new RuntimeException(String.format(
                "Assertion failed: element %s was not enabled",
                locator));
    }
}
 
Example 4
Project: opentest   File: AssertElementDisabled.java   View Source Code Vote up 6 votes
@Override
public void run() {

    super.run();

    By locator = this.readLocatorArgument("locator");

    this.waitForAsyncCallsToFinish();

    WebElement element = this.getElement(locator);
    if (element.isEnabled()) {
        throw new RuntimeException(String.format(
                "Assertion failed: element %s was not disabled",
                locator));
    }
}
 
Example 5
Project: autotest   File: WebTestBase.java   View Source Code Vote up 5 votes
/**
 * 判断元素是否存在
 *
 * @param webElement
 * @return
 */
public boolean isElementExist(WebElement webElement) {
    try {
        webElement.isEnabled();
        return true;
    } catch (NoSuchElementException e) {
        return false;
    }
}
 
Example 6
Project: ats-framework   File: RealHtmlRadioList.java   View Source Code Vote up 5 votes
/**
 * set the selected value
 *
 * @param value the value to select(this is the 'value' attribute of the radio button)
 */
@PublicAtsApi
public void select(
                    String value ) {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement element = RealHtmlElementLocator.findElement(this, "[@value='" + value + "']", true);
    if (!element.isEnabled()) {
        throw new UnsupportedOperationException("You may not select a disabled element." + toString());
    }
    element.click();

    UiEngineUtilities.sleep();
}
 
Example 7
Project: redirector   File: DistributionPage.java   View Source Code Vote up 5 votes
private WebElement waitForButton(WebElementFacade buttonFacade) {
    WebElement button = buttonFacade.withTimeoutOf(10, TimeUnit.SECONDS).waitUntilEnabled();

    if (!button.isEnabled()) {
        button = buttonFacade.withTimeoutOf(10, TimeUnit.SECONDS).waitUntilEnabled().waitUntilVisible();
    }

    return button;
}
 
Example 8
Project: POM_HYBRID_FRAMEOWRK   File: WebButton.java   View Source Code Vote up 5 votes
/**
 * Web button click.
 *
 * @param driver the driver
 * @param logger the logger
 * @param element the element
 */
public static void webButtonClick(WebDriver driver, ExtentTest logger, WebElement element) {
	try {
		if (element != null && element.isEnabled()) {
			element.click();
		}
	} catch (Exception e) {
		}
}
 
Example 9
Project: POM_HYBRID_FRAMEOWRK   File: WebTextbox.java   View Source Code Vote up 5 votes
/**
 * Checks if is web input editable.
 *
 * @param element
 *            the element
 * @return true, if is web input editable
 */
public static boolean isWebInputEditable(WebElement element) {
	boolean visibilityStatus = false;
	try {
		if (element != null) {
			visibilityStatus = element.isEnabled();
		}
	} catch (Exception e) {
		// nothing can be done at this point
	}
	return visibilityStatus;
}