I'm trying to surf inside an asp.net site with Java using HTMLUnit. When I request the final println at the bottom of the java code the console return just partial code instead of entire webpage's html... I've already tried to add waits for the JavaScripts and other common stuff like Xpath... anyone can help?
Here's my code:
public static HtmlPage submittingForm(String user, String pssw) throws Exception { java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.OFF);
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
webClient.getOptions().setThrowExceptionOnScriptError(false);
final HtmlPage page1 = webClient.getPage("someUrl");
final HtmlForm form1 = page1.getFormByName("someForm");
final HtmlTextInput username = form1.getInputByName("inputName");
username.setValueAttribute(user);
final HtmlPasswordInput password = form1.getInputByName("someName");
password.setValueAttribute(pssw);
final HtmlPage page2 = (HtmlPage) form1.getInputByValue(" Login ").click();
HtmlAnchor loginLink = page2.getAnchorByHref("anyHref");
HtmlPage page3 = loginLink.click();
final HtmlForm form2 = page3.getFormByName("formName");
lastPage = (HtmlPage) form2.getInputByValue("buttonName").click();
System.out.println(lastPage.asXml());
}
return lastPage;
}