Protractor : WebDriverError : could not initialize sun.security.ssl.SSLContextImpl$TLSContext
Protractor : WebDriverError : could not initialize sun.security.ssl.SSLContextImpl$TLSContext
刚接触量角器,开始教程就卡住了。我找不到错误的真正来源...
我做了什么:
- 安装量角器(
npm install -g protractor
)
- 更新和运行 webdriver-manager
- copy/paste 来自量角器教程的示例文件
- 运行 'protractor conf.js'
我得到的是:
[11:35:46] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:35:46] I/launcher - Running 1 instances of WebDriver
[11:35:46] E/launcher - Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
[11:35:46] E/launcher - WebDriverError: Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
at WebDriverError (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:458:24)
at Hosted.DriverProvider.getNewDriver (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/runner.js:198:43)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[11:35:46] E/launcher - Process exited with error code 199
备注
- 量角器:v4.0.14
- Java : openjdk 9-Ubuntu 9b134 (?)
- 系统:Ubuntu16.04
- NodeJS:v6.8.1
- 我在 conf.js
中使用 "capabilities.browserName:'firefox'" 得到相同的输出
欢迎任何帮助!
好吧,我会尝试猜测一下,因为我没有这方面的经验。
问题似乎如下:
Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
至少根据您显示的日志,并假设 Protractor 的所有设置都已正确完成。
这是 "stuff" 来自 JDK 代码。
让我们先看看为什么某些部分需要Java,因为它会帮助我们理解一些事情。
就在日志的第一行,很明显您正在使用硒服务器 (https://github.com/angular/protractor/blob/master/docs/server-setup.md)。
通过阅读上面的link可以看出,selenium服务器确实需要JDK,所以我们找到了一个Java“入口点”。
selenium 服务器是使用 webdriver-manager 启动的,因此在 webdriver-manager
的代码中必须有一些调用来启动 java.让我们看看它在哪里。
在这里查看源代码
https://github.com/angular/webdriver-manager/blob/70614a23e289088c852f5c0162a947488ffc77e0/lib/cmds/start.ts
我们可以看到java会在这里启动
let seleniumProcess = spawn('java', args, stdio);
这些参数定义如下:
let args: string[] = [];
这充满了这样的调用例如:
if (osType === 'Linux') {
// selenium server may take a long time to start because /dev/random is BLOCKING if there is not
// enough entropy the solution is to use /dev/urandom, which is NON-BLOCKING (use /dev/./urandom
// because of a java bug)
// https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/1301
// https://bugs.openjdk.java.net/browse/JDK-6202721
args.push('-Djava.security.egd=file:///dev/./urandom');
我注意到你提到你使用 OpenJDK 9,它现在可能还不可信,因为它还没有公开发布:
http://www.java9countdown.xyz/
http://openjdk.java.net/projects/jdk9/
我的第一个建议:使用生产稳定的 Java 版本,目前像 8,这似乎是我的 Ubuntu 16.04 中的默认版本机.
为了更好地了解您看到的错误可能源自何处,我建议阅读以下内容 post:
SSLContext initialization
以及那里的第一个答案,无论如何我觉得这很有启发性。您也可以在这里阅读:https://www.java.com/en/configure_crypto.html.
考虑到这一点,我建议必须启动 java 并启用以下系统 属性 jdk.tls.client.protocols
(尽管默认设置应该没问题...)。一种方法是添加以下行
args.push('-Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"');
例如在上述文件中调用 let seleniumProcess = spawn('java', args, stdio);
之前。
您还可以尝试什么
您可以检查是否可以通过将脚本直接连接到浏览器来避免此错误,而无需 selenium 服务器干预。如果您暂时 运行 在本地,这是可行的,并且应该更快,因为您避免了一跳。如果您的浏览器位于远程位置(暂时不是您的情况...),您需要 使用 selenium 服务器。
正如我在开头 linked 的 selenium 服务器设置页面中所述,确实列出了避免使用它的可能性。硒服务器设置文档中提到这一点的关键部分如下
Connecting Directly to Browser Drivers
Protractor can test directly against Chrome and Firefox without using
a Selenium Server. To use this, in your config file set directConnect: true
.
directConnect: true
- Your test script communicates directly Chrome
Driver or Firefox Driver, bypassing any Selenium Server. If this is
true, settings for seleniumAddress
and seleniumServerJar
will be
ignored. If you attempt to use a browser other than Chrome or Firefox
an error will be thrown. The advantage of directly connecting to
browser drivers is that your test scripts may start up and run faster.
因此,使用教程中使用的 conf.js,您将添加一行定义此额外配置,即
// conf.js
exports.config = {
directConnect: true
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js']
}
有些人报告说,将此选项与 Chrome 浏览器而不是 Firefox 结合使用已经解决了一些问题,但这些问题似乎与您的问题并不严格相关:
https://github.com/angular/angular-seed/issues/254
还有什么?
一些人还报告说,将 chrome 驱动程序更新到特定版本已经解决了使用 chrome 时 webdriver 中的一些问题,例如:
https://github.com/angular/protractor/issues/3640
https://github.com/angular/webdriver-manager/issues/102
因此,一个建议是尝试在相同的 运行ning 条件下使用 Chrome,看看你得到了什么。它可能 运行 没有问题。
请记住,在某些情况下,所有软件组件都依赖于特定版本的子组件(特定浏览器版本等),因此还要检查是否满足这些要求。这些在您使用的软件的相关页面中列出:量角器、webdriver-manager 等
再次强调,我既不是这些语言或框架的开发人员,所以 my view system 不是最好的和最有见识的系统。我还假设到 运行ning 点的设置已经正确完成。
刚接触量角器,开始教程就卡住了。我找不到错误的真正来源...
我做了什么:
- 安装量角器(
npm install -g protractor
) - 更新和运行 webdriver-manager
- copy/paste 来自量角器教程的示例文件
- 运行 'protractor conf.js'
我得到的是:
[11:35:46] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:35:46] I/launcher - Running 1 instances of WebDriver
[11:35:46] E/launcher - Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
[11:35:46] E/launcher - WebDriverError: Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
at WebDriverError (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:458:24)
at Hosted.DriverProvider.getNewDriver (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/runner.js:198:43)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[11:35:46] E/launcher - Process exited with error code 199
备注
- 量角器:v4.0.14
- Java : openjdk 9-Ubuntu 9b134 (?)
- 系统:Ubuntu16.04
- NodeJS:v6.8.1
- 我在 conf.js 中使用 "capabilities.browserName:'firefox'" 得到相同的输出
欢迎任何帮助!
好吧,我会尝试猜测一下,因为我没有这方面的经验。
问题似乎如下:
Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
至少根据您显示的日志,并假设 Protractor 的所有设置都已正确完成。
这是 "stuff" 来自 JDK 代码。
让我们先看看为什么某些部分需要Java,因为它会帮助我们理解一些事情。
就在日志的第一行,很明显您正在使用硒服务器 (https://github.com/angular/protractor/blob/master/docs/server-setup.md)。
通过阅读上面的link可以看出,selenium服务器确实需要JDK,所以我们找到了一个Java“入口点”。
selenium 服务器是使用 webdriver-manager 启动的,因此在 webdriver-manager
的代码中必须有一些调用来启动 java.让我们看看它在哪里。
在这里查看源代码
https://github.com/angular/webdriver-manager/blob/70614a23e289088c852f5c0162a947488ffc77e0/lib/cmds/start.ts
我们可以看到java会在这里启动
let seleniumProcess = spawn('java', args, stdio);
这些参数定义如下:
let args: string[] = [];
这充满了这样的调用例如:
if (osType === 'Linux') {
// selenium server may take a long time to start because /dev/random is BLOCKING if there is not
// enough entropy the solution is to use /dev/urandom, which is NON-BLOCKING (use /dev/./urandom
// because of a java bug)
// https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/1301
// https://bugs.openjdk.java.net/browse/JDK-6202721
args.push('-Djava.security.egd=file:///dev/./urandom');
我注意到你提到你使用 OpenJDK 9,它现在可能还不可信,因为它还没有公开发布:
http://www.java9countdown.xyz/
http://openjdk.java.net/projects/jdk9/
我的第一个建议:使用生产稳定的 Java 版本,目前像 8,这似乎是我的 Ubuntu 16.04 中的默认版本机.
为了更好地了解您看到的错误可能源自何处,我建议阅读以下内容 post:
SSLContext initialization
以及那里的第一个答案,无论如何我觉得这很有启发性。您也可以在这里阅读:https://www.java.com/en/configure_crypto.html.
考虑到这一点,我建议必须启动 java 并启用以下系统 属性 jdk.tls.client.protocols
(尽管默认设置应该没问题...)。一种方法是添加以下行
args.push('-Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"');
例如在上述文件中调用 let seleniumProcess = spawn('java', args, stdio);
之前。
您还可以尝试什么
您可以检查是否可以通过将脚本直接连接到浏览器来避免此错误,而无需 selenium 服务器干预。如果您暂时 运行 在本地,这是可行的,并且应该更快,因为您避免了一跳。如果您的浏览器位于远程位置(暂时不是您的情况...),您需要 使用 selenium 服务器。
正如我在开头 linked 的 selenium 服务器设置页面中所述,确实列出了避免使用它的可能性。硒服务器设置文档中提到这一点的关键部分如下
Connecting Directly to Browser Drivers
Protractor can test directly against Chrome and Firefox without using a Selenium Server. To use this, in your config file set
directConnect: true
.
directConnect: true
- Your test script communicates directly Chrome Driver or Firefox Driver, bypassing any Selenium Server. If this is true, settings forseleniumAddress
andseleniumServerJar
will be ignored. If you attempt to use a browser other than Chrome or Firefox an error will be thrown. The advantage of directly connecting to browser drivers is that your test scripts may start up and run faster.
因此,使用教程中使用的 conf.js,您将添加一行定义此额外配置,即
// conf.js
exports.config = {
directConnect: true
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js']
}
有些人报告说,将此选项与 Chrome 浏览器而不是 Firefox 结合使用已经解决了一些问题,但这些问题似乎与您的问题并不严格相关: https://github.com/angular/angular-seed/issues/254
还有什么?
一些人还报告说,将 chrome 驱动程序更新到特定版本已经解决了使用 chrome 时 webdriver 中的一些问题,例如:
https://github.com/angular/protractor/issues/3640
https://github.com/angular/webdriver-manager/issues/102
因此,一个建议是尝试在相同的 运行ning 条件下使用 Chrome,看看你得到了什么。它可能 运行 没有问题。
请记住,在某些情况下,所有软件组件都依赖于特定版本的子组件(特定浏览器版本等),因此还要检查是否满足这些要求。这些在您使用的软件的相关页面中列出:量角器、webdriver-manager 等
再次强调,我既不是这些语言或框架的开发人员,所以 my view system 不是最好的和最有见识的系统。我还假设到 运行ning 点的设置已经正确完成。