title: HtmlUnit form submit since button does not have a direct hyperlink
body: <p>I have a button on a page but there is no hyperlink in the button. So I need to submit the form to go to the next page.</p>
  
  <p>HtmlUnit is not waiting till the next page loads. So the <code>nextPage</code> variable is having the current page instead of the next page (intermittently it works if page loads quick enough though). How to resolve this?</p>
  
  <p>Html Page:</p>
  
  <pre><code>    &lt;form action="/webapp/NewPage.jsp" id="idForm01" accept-charset="UNKNOWN" onsubmit="return false;" 
      name="frmNewPageForm" method="post" enctype="application/x-www-form-urlencoded"&gt;
                     &lt;input name="attribute1" type="HIDDEN" value="1"&gt;
  
                     &lt;input id="attribute2" value="EDIT_ATTRIBUTE2" name="functionalAttribute" type="hidden"&gt;
  
                  &lt;/form&gt;
  
  
                  &lt;table id="idTablePageDetails" class="formTable"&gt;
  
                     &lt;tbody&gt;
                      &lt;tr class="formHeaderRow"&gt;
                        &lt;td colspan="4" nowrap=""&gt;
                           Page Details
  
                           &lt;a onclick="onClick_newPageButton();return false;" id="newPageButton" title="New Page" href="#" class="smallButton"&gt;
          &lt;img id="image" border="0" class="smallButtonImg" src="/webapp/image/imageButton.png"&gt;&lt;/a&gt;
  
                           &lt;script type="text/javascript" language="Javascript"&gt;
                          &lt;!--
                          function onClick_newPageButton() {
                             buttonAction_newPageButton();
                          }
                          function buttonAction_newPageButton() {   
              if ( allowClick() == true ) { addFormField( "frmNewPageForm", "action", "ACTION_NEW_PAGE" );
              if ( document.frmNewPageForm.onsubmit != null ) { document.frmNewPageForm.onsubmit(); }document.frmNewPageForm.submit(); }}
                          // --&gt;
                          &lt;/script&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p>Code I am using to get the next page:</p>
  
  <pre><code>HtmlPage nextPage = (HtmlPage) page.executeJavaScript("document.frmNewPageForm.onsubmit()").getNewPage(); // from onsubmit
  </code></pre>