0

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..

1 Answer 1

2

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(); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.