Selenium Webdriver上的代理问题

时间:2019-05-28 14:08:45

标签: java selenium google-chrome openssl

我正在使用Java运行硒测试。 我已使用以下代码配置了google chrome:

  private void configureChromeOptions() {
    File file = new File(appParams.getDrivers().getChromeDriverPath());
    System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());

    chromeOptions = new ChromeOptions();
    chromeOptions.setBinary(appParams.getDrivers().getChromeBinariesPath());
    chromeOptions.addArguments("--start-maximized");
    chromeOptions.addArguments("--no-sandbox");
    chromeOptions.addArguments("--disable-setuid-sandbox");
    chromeOptions.addArguments("--ignore-certificate-errors");

    Map<String, Object> prefs = new HashMap<>();
    //Turns off multiple download warning
    prefs.put("profile.content_settings.pattern_pairs.*.multiple-automatic-downloads", Integer.valueOf(1));
    //Turns off download prompt
    prefs.put("download.prompt_for_download", Boolean.valueOf(false));
    prefs.put("profile.default_content_settings.popups", Integer.valueOf(0));
    prefs.put("download.default_directory", System.getProperty("user.home"));
    chromeOptions.setExperimentalOption("prefs", prefs);

    Proxy proxy = new Proxy();
    proxy.setHttpProxy(System.getProperty("http.proxyHost"));
    proxy.setSslProxy(System.getProperty("https.proxyHost"));
    logger.info("Configuring proxy with: ", System.getProperty("http.proxyHost"));

    chromeCapabilities = new DesiredCapabilities();
    chromeCapabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
  }

但是当我尝试访问网页时,出现以下错误:

"This site can’t be reached www.mywebsite.com is currently unreachable. Try: Checking the connection Checking the proxy and the firewall ERR_SSL_VERSION_INTERFERENCE null Reload Details Check your Internet connection Check any cables and reboot any routers, modems, or other network devices you may be using. Allow Chrome to access the network in your firewall or antivirus settings. If it is already listed as a program allowed to access the network, try removing it from the list and adding it again. If you use a proxy server… Check your proxy settings or contact your network administrator to make sure the proxy server is working. If you don't believe you should be using a proxy server: Go to the Chrome menu > Settings > Show advanced settings… > Change proxy settings… and make sure your configuration is set to "no proxy" or "direct." www.mywebsite.com is currently unreachable."

如果我尝试通过curl访问相同的网页,那么只要使用这些键,我就没问题:

curl --proxy localhost:13128 -L -k --cert mycert.crt --key mycert.key -u username:password https://www.mywebsite.com

此访问没有任何问题。我正在使用cntlm进行代理身份验证。 相同的代码在docker映像中运行没有问题。

什么可能导致此代理问题?

0 个答案:

没有答案