ChromeDriver ERR_SSL_PROTOCOL_ERROR despite –allow-insecure-localhost

huangapple 未分类评论46阅读模式
英文:

ChromeDriver ERR_SSL_PROTOCOL_ERROR despite --allow-insecure-localhost

问题

我有一些使用ChromeDriver进行Selenium测试的代码,我正在使用ChromeDriver访问https://localhost:<port>。在这种情况下,端口号使用自签名证书来支持HTTPS连接。

然而,当ChromeDriver打开并尝试导航到该本地地址时,Chrome会显示一个错误页面,错误为ERR_SSL_PROTOCOL_ERROR,如下面的截屏所示。
ChromeDriver ERR_SSL_PROTOCOL_ERROR despite –allow-insecure-localhost

我进行了一些研究,并发现可以在WebDriver实例的capabilities对象中添加开关--allow-insecure-localhost--ignore-certificate-errors这个问题/答案给了我一些想法。我创建capabilities的代码如下:

ChromeOptions options = new ChromeOptions();
// 其他capabilities在这里
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
options.addArguments("--allow-insecure-localhost", "--ignore-certificate-errors");

尽管如此,当ChromeDriver实例尝试导航到本地主机时,我仍然会得到相同的错误页面。

我正在使用ChromeDriver 84.0.4147.30和Google Chrome版本84.0.4147.89

我该如何解决这个问题?

英文:

I have Selenium tests where I'm using ChromeDriver to go to https://localhost:&lt;port&gt;. The port number in this case is using a self-signed certificate to support HTTPS connection.

However, when ChromeDriver opens and tries to navigate to that localhost address, Chrome gives an error screen ERR_SSL_PROTOCOL_ERROR as seen in screenshot below.
ChromeDriver ERR_SSL_PROTOCOL_ERROR despite –allow-insecure-localhost

I did some research and found that adding the switches --allow-insecure-localhost and --ignore-certificate-errors to the capabilities object for the WebDriver instance. This question/answer gave me some ideas. My code for creating the capabilities is:

ChromeOptions options = new ChromeOptions();
// Other capabilities here
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
options.addArguments(&quot;--allow-insecure-localhost&quot;, &quot;--ignore-certificate-errors&quot;);

Nonetheless, I still get the same error screen when the ChromeDriver instance tries to navigate to localhost.

I'm using ChromeDriver 84.0.4147.30 and Google Chrome Version 84.0.4147.89

How do I resolve this issue?

huangapple
  • 本文由 发表于 2020年7月24日 05:07:49
  • 转载请务必保留本文链接:https://java.coder-hub.com/63063145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定