org.openqa.selenium.ElementNotInteractableException Java Examples

The following examples show how to use org.openqa.selenium.ElementNotInteractableException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DomElementTest.java    From htmlunit with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception on test failure
 */
@Test(expected = ElementNotInteractableException.class)
public void clickHiddenSubmit() throws Exception {
    final String html = "<!DOCTYPE html>\n"
        + "<html><head></head>\n"
        + "<body>\n"
        + "  <form id='myForm' action='" + URL_SECOND + "'>\n"
        + "    <input id='myButton' type='submit' style='display: none;'>Submit</input>\n"
        + "  </form>\n"
        + "</body></html>";
    final String secondContent = "second content";

    getMockWebConnection().setResponse(URL_SECOND, secondContent);

    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("myButton")).click();
}
 
Example #2
Source File: SynchExplicitTest.java    From demo-java with MIT License 6 votes vote down vote up
@Test
public void synchronizeExplicit() {
    driver.get("http://watir.com/examples/wait.html");
    WebDriverWait wait = new WebDriverWait(driver, 30);

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("add_foobar")));
    driver.findElement(By.id("add_foobar")).click();

    WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("foobar")));

    try {
        element.click();
        session.stop(true);
    } catch (ElementNotInteractableException e) {
        session.stop(false);
        Assert.assertTrue(e.getMessage(), false);
    }
}
 
Example #3
Source File: RealHtmlElement.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Simulate mouse click action
 */
@Override
@PublicAtsApi
public void click() {

    new RealHtmlElementState(this).waitToBecomeExisting();

    try {
        WebElement element = RealHtmlElementLocator.findElement(this);
        try {
            element.click();
        } catch (ElementNotInteractableException enie) {
            if (!UiEngineConfigurator.getInstance().isWorkWithInvisibleElements()) {
                throw enie;
            }
            ((JavascriptExecutor) webDriver).executeScript("arguments[0].click()", element);
        }
    } catch (Exception e) {
        throw new SeleniumOperationException(this, "click", e);
    }
}
 
Example #4
Source File: DomElementTest.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception on test failure
 */
@Test(expected = ElementNotInteractableException.class)
public void clickInvisible() throws Exception {
    final String html = "<html>\n"
            + "<body>\n"
            + "  <a id='link' style='display: none'>Click me</a>\n"
            + "</body></html>";

    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("link")).click();
}
 
Example #5
Source File: SynchSalsaVerdeTest.java    From demo-java with MIT License 5 votes vote down vote up
@Test
public void synchronizeSalsaVerde() {
    browser.goTo("http://watir.com/examples/wait.html");

    browser.element(By.id("add_foobar")).click();

    try {
        browser.element(By.id("foobar")).click();
        session.stop(true);
    } catch (ElementNotInteractableException e) {
        session.stop(false);
        Assert.assertTrue(e.getMessage(), false);
    }
}
 
Example #6
Source File: SynchAbstractTest.java    From demo-java with MIT License 5 votes vote down vote up
@Test
public void synchronizeAbstract() {
    driver.get("http://watir.com/examples/wait.html");

    click(By.id("add_foobar"));

    try {
        click(By.id("foobar"));
        session.stop(true);
    } catch (ElementNotInteractableException e) {
        session.stop(false);
        Assert.assertTrue(e.getMessage(), false);
    }
}
 
Example #7
Source File: KcPassword.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public void clickEyeButton() {
    if (isEyeButtonDisabled()) {
        throw new ElementNotInteractableException("The eye button is disabled and cannot be clicked");
    }
    eyeButton.click();
}