Skip to content

Commit 591da5b

Browse files
committed
avoid using XPath for implementing form submit on enter key pressed
1 parent 380bf3e commit 591da5b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/htmlunit/html/HtmlElement.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,12 @@ private Page type(final char c, final boolean lastType)
605605

606606
final HtmlForm form = getEnclosingForm();
607607
if (form != null && c == '\n' && isSubmittableByEnter()) {
608-
final HtmlSubmitInput submit = form.getFirstByXPath(".//input[@type='submit']");
609-
if (submit != null) {
610-
return submit.click();
608+
for (final DomElement descendant : form.getDomElementDescendants()) {
609+
if (descendant instanceof HtmlSubmitInput) {
610+
return descendant.click();
611+
}
611612
}
613+
612614
form.submit((SubmittableElement) this);
613615
webClient.getJavaScriptEngine().processPostponedActions();
614616
}

0 commit comments

Comments
 (0)