HtmlUnit How to Submit Form without Submit Button

Submitted by admin on 2011-10-16 21:37:25

When we are testing with HtmlUnit, sometimes the form is submitted by JS and we do not want HtmlUnit to turn on JS support, then we need to do this:


HtmlForm form = page.getFormByName("formName");
HtmlButton submitButton = (HtmlButton)page.createElement("button");
submitButton.setAttribute("type", "submit");
HtmlPage newPage =;
hi jacob, so what's your solution at the end? I found this is useful to me.
Hello for me this is streange, how itis possible that such lib does not have function form.submit,also those guzs on forum tell that you can use js to fire event for submision, i reallz dont lie it because i must waste time for such little stupid thing i even tried httpunit but guess what, it does not allow to set hidden inputs lol each lib is so crappy
We tried to integrate Selenium into our aetomatud build system, but after running into a number of obstacles, we sort of put it on the back shelf.We might try it again soon, though. The more Ajax-y and Javascripty stuff we use, the more nervous I get about test coverage.
Add Your Comment Here:
Your Name:(required)
Your Email:(required) We won't publish your email!
Are you human? Please input the characters above.