7 Replies Latest reply on Feb 19, 2013 8:37 AM by 990745

    Getting a Proxy Authentication error with HTMLUnit


      I am using HTML Unit to automate a Google Search. I am using the proxy server of my organisation. The following lines of code

      final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10, "", 80);

           //set proxy username and password
           final DefaultCredentialsProvider credentialsProvider = (DefaultCredentialsProvider) webClient.getCredentialsProvider();
           credentialsProvider.addCredentials("mysusername", "mypassword");

           final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net");


      gives me the error "407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) for http://htmlunit.sourceforge.net/". I am supplying my username and password to the defaultCredentialsProvider. I also tried setting System property for proxyPort and ProxyHost as follows


      but I guess HTMLUnit uses httpclient internally for authentication which ignores the JVM flags. Can anybody give me some pointers on the solution.