HTMLUnit not redirecting to actual webpage

338 Views Asked by At

I am trying to download some files from this site.

The site initially lands at a loading screen later it will redirect to the original site where we need to enter the logins. But the HTMLUnit is not taking us to the login page.

    WebClient webClient = new WebClient(BrowserVersion.CHROME);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    webClient.getOptions().setRedirectEnabled(true);
    webClient.getOptions().setJavaScriptEnabled(true);
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    webClient.getOptions().setThrowExceptionOnScriptError(false);

    WebRequest request = new WebRequest(new URL("https://eportal.incometax.gov.in/iec/foservices/#/login"), HttpMethod.GET);
    HtmlPage page = webClient.getPage(request);
    webClient.waitForBackgroundJavaScript(100000);
    webClient.waitForBackgroundJavaScriptStartingBefore(10000);

    HtmlInput htmlInput = (HtmlInput) page.getElementById("panAdhaarUserId");
    System.err.println(htmlInput); //it is giving null value 
    System.err.prinln(page.asText()); //it is printing the initial loading screen only
0

There are 0 best solutions below