提交 fd4fdc91 编写于 作者: T tfennelly

Don't click and submit if it's a SubmitableElement

上级 bc88d212
......@@ -46,7 +46,9 @@ public class HtmlFormUtil {
* Plain {@link com.gargoylesoftware.htmlunit.html.HtmlForm#submit()} doesn't work correctly due to the use of YUI in Hudson.
*/
public static Page submit(HtmlForm htmlForm, HtmlElement submitElement) throws IOException {
if (submitElement != null) {
if (submitElement == null || submitElement instanceof SubmittableElement) {
htmlForm.submit((SubmittableElement) submitElement);
} else {
// To make YUI event handling work, this combo seems to be necessary
// the click will trigger _onClick in buton-*.js, but it doesn't submit the form
// (a comment alluding to this behavior can be seen in submitForm method)
......@@ -57,9 +59,6 @@ public class HtmlFormUtil {
// triggered a submission (more concretely, m_oSubmitTrigger is not set.)
submitElement.click();
}
if (submitElement instanceof SubmittableElement) {
htmlForm.submit((SubmittableElement) submitElement);
}
return htmlForm.getPage();
}
......@@ -87,10 +86,7 @@ public class HtmlFormUtil {
}
for (HtmlElement element : htmlForm.getHtmlElementsByTagName("button")) {
if(element instanceof HtmlButton) {
HtmlButton button = (HtmlButton) element;
if (button.isSubmittableByEnter()) {
return element;
}
return element;
}
}
return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册