I am trying to enter a Facebook page using HtmlUnit and view its HTML content. I am trying to fill in the login credentials through HtmlUnit, but I do not see that the session is transferred when the submit button is clicked.
Could not find a lot of content for the htmlunit session management classes. I also added the code that I am using now to try to solve this problem. Any help appreciated!
WebClient webClient = new WebClient(); HtmlPage page1 = webClient.getPage("https://www.facebook.com"); List<HtmlForm> listF = page1.getForms(); HtmlForm form = null; for(int i=0; i<listF.size(); i++) { if(listF.get(i).getId().equals("login_form")) { form = listF.get(i); } } HtmlTextInput uName = form.getInputByName("email"); HtmlPasswordInput passWord = form.getInputByName("pass"); HtmlSubmitInput button = form.getInputByValue("Log In"); uName.setValueAttribute(FACEBOOK_UNAME); passWord.setValueAttribute(FACEBOOK_PASS); HtmlPage page2 = button.click();
source share