public static WebClient buildWebClient() {
    WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    webClient.getOptions().setCssEnabled(true);
    webClient.getOptions().setJavaScriptEnabled(true);
    webClient.getOptions().setUseInsecureSSL(true);

    webClient.setCssErrorHandler(
        new ErrorHandler() {
          @Override
          public void warning(CSSParseException exception) throws CSSException {
            // nothing to do here
          }

          @Override
          public void error(CSSParseException exception) throws CSSException {
            // todo: log or throw exception
          }

          @Override
          public void fatalError(CSSParseException exception) throws CSSException {
            // todo: log or throw exception
          }
        });

    webClient.setIncorrectnessListener(
        new IncorrectnessListener() {
          @Override
          public void notify(String message, Object origin) {
            // todo: analyze and throw exception
          }
        });

    webClient.waitForBackgroundJavaScript(100000);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getOptions().setRedirectEnabled(true);

    return webClient;
  }