0

I tried log-in into HTTPS site with below webclient configuration but seems I'm unable to login.

    final WebClient webClient = new WebClient(BrowserVersion.getDefault(), "10.52.252.31", 8080);
    webClient.getOptions().setJavaScriptEnabled(true);
    webClient.getCookieManager().setCookiesEnabled(true);
    webClient.getOptions().setRedirectEnabled(true);
    webClient.getOptions().setCssEnabled(false);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    webClient.getOptions().setAppletEnabled(true);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    webClient.waitForBackgroundJavaScript(100000);
    webClient.getOptions().setUseInsecureSSL(true);

Please provide sample code if there is any workaround.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
  • Disabling `setThrowExceptionOnScriptError` prevents you from seeing the errors, please ensure you use HtmlUnit 2.17 and provide the complete case with the URL used. – Ahmed Ashour Jul 01 '15 at 12:59
  • Please be more specific. Where is the code that tries to log in, what is the failure? Did you manage to load the login page, i.e. is https working? – Felix Leipold Jul 01 '15 at 13:47
  • Did you try to specify protocoly explicitly as `"https://example.com"` ? – Andrew Jul 01 '15 at 21:11

1 Answers1

0

I got the answer on following link.

http://www.reddit.com/r/learnprogramming/comments/2q6gma/javahow_to_web_scrape_a_site_behind_a_log_in/

Actually we should use Xpath while logging into HTTPS site insted of getElementById method in HtmlUnit and it solve the purpose.