Note that there are some explanatory texts on larger screens.

plurals
  1. POHtmlUnit, trying to get 2 forms, get exception at second form
    primarykey
    data
    text
    <p>Currently using HtmlUnit.</p> <p>Getting first login page is no problem, succesfully logging in, getting next page, "clicking" the link to get the "MyDetails" page. </p> <p>After getting "MyDetails" page, i want to get the same way as im getting the first login form. </p> <p>Why i need to get the form is that i want to change the password, and the fields are in a form. </p> <p>When im trying to get the second form, it gives me exception as follows:</p> <p>com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[form] attributeName=[name] attributeValue=[form2]</p> <p>Gives exception at this line of code:</p> <pre><code>HtmlForm form2 = page3.getFormByName("form2"); </code></pre> <p>Note: the first form name is "form1" &amp; second form name is "form2".</p> <p>Is this a problem with HtmlUnit?</p> <p>Code:</p> <pre><code>try { WebClient webclient = new WebClient(BrowserVersion.FIREFOX_3_6); HtmlPage page1 = webclient.getPage("http://www.highveld.mobi/pages/clubvip/login.aspx"); HtmlForm form = page1.getFormByName("form1"); HtmlSubmitInput buttonLogin = form.getInputByName("cmdLogin"); HtmlTextInput cellLogin = form.getInputByName("txtCellNumber"); HtmlPasswordInput passLogin = form.getInputByName("txtLoginPassword"); cellLogin.setValueAttribute(change); passLogin.setValueAttribute(oldPass); HtmlPage page2 = buttonLogin.click(); HtmlAnchor link = page2.getAnchorByHref("updateprofile.aspx"); HtmlPage page3 = link.click(); System.out.println(page3.getUrl()); HtmlForm form2 = page3.getFormByName("form2"); HtmlPasswordInput pass = form2.getInputByName("txtPassword"); HtmlPasswordInput passConfirm = form2.getInputByName("txtConfirmPassword"); HtmlSubmitInput button = form2.getInputByName("cmdUpdate"); pass.setValueAttribute(newPass); passConfirm.setValueAttribute(newPass); HtmlPage page4 = button.click(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload