Skip to content

Commit

Permalink
throw JavascriptException like the other drivers do
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 17, 2020
1 parent 665995f commit 4c492e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.InvalidElementStateException;
import org.openqa.selenium.InvalidSelectorException;
import org.openqa.selenium.JavascriptException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.Point;
Expand Down Expand Up @@ -151,13 +152,13 @@ void submitImpl() {
} else if (element instanceof HtmlInput) {
HtmlForm form = ((HtmlElement) element).getEnclosingForm();
if (form == null) {
throw new NoSuchElementException("Unable to find the containing form");
throw new JavascriptException("Unable to find the containing form");
}
submitForm(form);
} else {
HtmlUnitWebElement form = findParentForm();
if (form == null) {
throw new NoSuchElementException("Unable to find the containing form");
throw new JavascriptException("Unable to find the containing form");
}
form.submitImpl();
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/openqa/selenium/FormHandlingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public void testShouldNotBeAbleToSubmitAFormThatDoesNotExist() {
driver.get(pages.formPage);
WebElement element = driver.findElement(By.name("SearchableText"));
Throwable t = catchThrowable(element::submit);
assertThat(t, instanceOf(NoSuchElementException.class));
// assertThat(t, instanceOf(NoSuchElementException.class));
assertThat(t, instanceOf(JavascriptException.class));
}

@Test
Expand Down

0 comments on commit 4c492e8

Please sign in to comment.