【问题标题】:Why is Selenium webdriver is not opening webpage?为什么 Selenium webdriver 没有打开网页?
【发布时间】:2019-12-10 09:25:21
【问题描述】:

您好,我正在尝试使用 Selenium 连接到浏览器堆栈上的远程 webdriver,但每当页面在 Chrome 和 Firefox 中加载时,我都会收到一条安全消息(见下图)。

我的 URL 以 https:// 开头(当我手动打开浏览器时,我必须接受证书并在网页加载之前继续)

我已将此行添加到我的代码中,但似乎没有任何区别:

 capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
 capability.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, "true");
 capability.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);

注意:只有在测试在 GoCD 管道上运行时才会出现此问题。在 intellij 上运行时一切正常

错误:

org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=nssFailure2&u=https%3A//transport....

在 chrome 中我看到了这个:

在 Firefox 中我收到类似的消息:

【问题讨论】:

  • 您可能需要启用本地测试。 Please find the documentation here
  • @SoorajSathianandan 我已经启用它但仍然收到错误:capability.setCapability("browserstack.local", "true");
  • 您是否使用 BrowserstackLocal 设置隧道?

标签: selenium selenium-webdriver automated-tests browserstack remotewebdriver


【解决方案1】:

您可以尝试添加如下内容并测试:

 ChromeOptions chromeOptions = new ChromeOptions();
 chromeOptions.addArguments("ignore-certificate-errors");
 capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
 options.addArguments("--test-type");
 capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

【讨论】:

    【解决方案2】:
      ChromeOptions chromeOptions = new ChromeOptions();
      chromeOptions.AddArguments("disable-gpu");
      chromeOptions.AddArguments("window-size=1980,1080");
      Driver = new ChromeDriver(chromeOptions);
    

    【讨论】:

    • 我怀疑这是否会对安全证书产生任何影响。你能用关于它的动态的详细描述来支持这一点吗?
    【解决方案3】:

    我已经找到问题供任何人将来参考。

    这是因为我们在 GocD 上的主机名没有转发 DNS 请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 2019-02-10
      相关资源
      最近更新 更多