Reputation: 537
I am trying to login on a page with HtmlUnit, but is seems like the login-button is a javascript-link. This is the page: https://www.talkmore.no/talkmore3/servlet/Login
I find the username/password input, and adding value to this, but not the submit button.
This is my code:
HtmlPage page = (HtmlPage) webClient.getPage("https://www.talkmore.no/talkmore3/servlet/Login");
HtmlForm form = page.getFormByName("login");
List<HtmlInput> inputs = getInputs(form);
form.getInputByName("username").setValueAttribute("user");
form.getInputByName("password").setValueAttribute("pass");
page = form.getInputByValue("Login").click();
Innputs in the form:
[HtmlTextInput[<input class="inputModern" style="width: 100px;" maxlength="8" name="username" type="text" value="">], HtmlPasswordInput[<input class="inputModern" style="width: 100px;" name="password" type="password" value="">]]
No sign for submit..
Upvotes: 0
Views: 379
Reputation: 16184
Viewing the page's source you can see that it uses JS to submit the form:
<a href="javascript:document.login.submit();"><span>Logg inn</span></a>
I'm not familiar with HtmlUnit but could you not trigger a click on that? Something like (this is mostly guesswork):
HTMLAnchor anchor = page.getAnchorByHref("javascript:document.login.submit();");
anchor.click();
Upvotes: 2