Skip to content

Commit

Permalink
submit should throw NoSuchElementException if the target element is not
Browse files Browse the repository at this point in the history
within a form. Implemented in atoms, Firefox and HtmlUnit.
  • Loading branch information
barancev committed Mar 12, 2013
1 parent 9bebcaf commit 528354c
Show file tree
Hide file tree
Showing 6 changed files with 8,252 additions and 8,202 deletions.
16,439 changes: 8,243 additions & 8,196 deletions cpp/IEDriver/Generated/atoms.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ public void submit() {
element.click();
return;
} else if (element instanceof HtmlInput) {
submitForm(element.getEnclosingForm());
HtmlForm form = element.getEnclosingForm();
if (form == null) {
throw new NoSuchElementException("Unable to find the containing form");
}
submitForm(form);
return;
}

Expand Down
3 changes: 1 addition & 2 deletions java/client/test/org/openqa/selenium/FormHandlingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import static org.junit.Assume.assumeTrue;
import static org.openqa.selenium.TestWaiter.waitFor;
import static org.openqa.selenium.WaitingConditions.pageTitleToBe;
import static org.openqa.selenium.testing.Ignore.Driver.ALL;
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
Expand Down Expand Up @@ -100,7 +99,7 @@ public void testShouldSubmitAFormWhenAnyElementWihinThatFormIsSubmitted() {
}

@Test
@Ignore(ALL)
@Ignore(value = {ANDROID, CHROME, IE, IPHONE, OPERA, PHANTOMJS, SAFARI, SELENESE, OPERA_MOBILE})
public void testShouldNotBeAbleToSubmitAFormThatDoesNotExist() {
driver.get(pages.formPage);

Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bot.action.type = function(
bot.action.submit = function(element) {
var form = bot.action.LegacyDevice_.findAncestorForm(element);
if (!form) {
throw new bot.Error(bot.ErrorCode.INVALID_ELEMENT_STATE,
throw new bot.Error(bot.ErrorCode.NO_SUCH_ELEMENT,
'Element was not in a form, so could not submit.');
}
bot.action.LegacyDevice_.submitForm(element, form);
Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ bot.Device.isForm_ = function(node) {
bot.Device.prototype.submitForm = function(form) {
if (!bot.Device.isForm_(form)) {
throw new bot.Error(bot.ErrorCode.INVALID_ELEMENT_STATE,
'Element was not in a form, so could not submit.');
'Element is not a form, so could not submit.');
}
if (bot.events.fire(form, bot.events.EventType.SUBMIT)) {
// When a form has an element with an id or name exactly equal to "submit"
Expand Down
2 changes: 1 addition & 1 deletion javascript/firefox-driver/js/wrappedElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ WebElement.submitElement = function(respond, parameters) {
return;
}
} else {
throw new WebDriverError(bot.ErrorCode.INVALID_ELEMENT_STATE,
throw new WebDriverError(bot.ErrorCode.NO_SUCH_ELEMENT,
"Element was not in a form so couldn't submit");
}
}
Expand Down

0 comments on commit 528354c

Please sign in to comment.