views:

18

answers:

1

Do you know what can I do to check if proxy in WebBrowser is working properly?

+1  A: 
  1. Well, if the proxy does not exist, you will have an error:

    WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8, "localhost", 8080);
    HtmlPage page = webClient.getPage("http://htmlunit.sf.net");
    System.out.println(page.asText());
    
org.apache.http.conn.HttpHostConnectException:

Connection to http://localhost:8080 refused at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)

  1. If the proxy misbehaves, you will have a different page than what you expected
Ahmed Ashour
Can I catch it by try and catch ?
oneat
Sure you can, why not?
Ahmed Ashour