Currently I am trying to login to LinkedIn using HtmlUnit 2.20. But I am not able to login. Below is my code.
public static void Login(String username, String password) { final WebClient webClient = new WebClient(BrowserVersion.CHROME); try { final HtmlPage page = webClient.getPage "https://www.linkedin.com/secure/login"); final HtmlForm form = page.getForms().get(0); final HtmlSubmitInput button = form.getInputByName("signin"); final HtmlTextInput emailBtn = form.getInputByName("session_key"); final HtmlPasswordInput passBtn = form.getInputByName("session_password"); emailBtn.setValueAttribute(username); passBtn.setValueAttribute(password); final HtmlPage page2 = button.click(); System.out.println(page2.getWebResponse().getContentAsString()); } catch (Exception ex ){ ex.printStackTrace(); } }
Could you please assist in finding what is wrong with my code and how do I navigate to another page after I login.