当前位置: 首页 > 知识库问答 >
问题:

量角器:WebDriverError:无法初始化Sun.Security.SSL.SSLContexTIMPL$TLSContext

郑佐
2023-03-14

我对量角器刚刚入门,开始教程的时候就被堵了。我找不到错误的真正来源...

我所做的:

    null
[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
    null

欢迎任何帮助!

共有1个答案

柳梓
2023-03-14

嗯,我试着猜测一下,因为我在这方面没有经验。
问题似乎是这样的:

无法初始化类Sun.Security.SSL.SSLContexTIMPL$TLSContext

至少根据您所显示的日志,并且假设量角器的所有设置都已正确完成。

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');  

我注意到您提到您使用OpenJDK9,它现在可能还不是可信任的,因为它还没有发布以供普遍使用:
http://www.java9countdown.xyz/
http://OpenJDK.java.net/projects/jdk9/

我的第一个建议是:使用一个稳定的Java生产版本,比如目前的8版本,这似乎是我的Ubuntu16.04机器的默认版本。

要对您看到的错误可能源自何处有一个好的感觉,我建议阅读下面的SO post:
SSLContext initialization and the first answer in the there,我觉得这篇文章很有启发意义。您还可以在这里阅读:https://www.java.com/en/configure_crypto.html。

因此,我建议在启动java时使用以下系统属性jdk.tls.client.protocols(尽管默认值应该是OK...)。一种方法是添加以下一行

args.push('-Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"');

例如,在调用之前,在上面提到的文件中设置seleniumProcess=spawn('java',args,stdio);

您还可以尝试什么
您可以检查是否可以通过将脚本直接连接到浏览器来避免此错误,而不需要selenium服务器的干预。如果您暂时在本地运行,这是可行的,并且应该更快,因为您避免了一跳。如果您的浏览器位于远程(暂时不是您的情况...)您需要使用selenium服务器。

正如我在开头链接的selenium服务器设置页面中所述,这种避免使用它的可能性确实列出了。selenium服务器安装文档中提到这一点的关键部分如下

直接连接到浏览器驱动程序

directconnect:true-您的测试脚本直接与Chrome驱动程序或Firefox驱动程序通信,绕过任何Selenium服务器。如果为真,则SeleniumAddressSeleniumServerJar的设置将被忽略。如果您尝试使用Chrome或Firefox以外的浏览器,则会抛出一个错误。直接连接到浏览器驱动程序的好处是,您的测试脚本可能会更快地启动和运行。

因此,在使用教程中的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

还有什么?一些人还报告说,将chromedriver更新到特定版本解决了使用chrome时webdriver中的一些问题,例如:https://github.com/angular/protractor/issues/3640
https://github.com/angular/webdriver-manager/issues/102
,所以一个建议是尝试在相同的运行条件下使用chrome并看看您得到了什么。运行起来可能不会有问题。

请记住,在某些情况下,所有软件组件都依赖于子组件的特定版本(特定浏览器版本等),因此也要检查是否满足了这些要求。这些在您使用的软件的相关页面中列出:量角器、webdriver-manager等。

再次强调一个事实,我既不是这些语言或框架的开发人员,所以我对系统的看法并不是最好的,也不是最有见地的。我还假设到运行点的设置已经做得正确。

 类似资料:
  • 在我的Spring应用程序中,我实现了一个自定义的身份验证提供商,它使用服务来处理我的登录请求。身份验证提供程序如下: https://github.com/klebermo/webapp_horario_livre/blob/master/src/com/horariolivre/security/CustomAuthenticationProvider.java 我的服务级别是: https:

  • 我有一个使用MIP SDK的Azure函数,当调用< code>MIP时,我得到以下错误。CreateMipContext(...): 令人惊讶的是,该错误仅在 Azure 上运行时发生。在本地运行时,一切都很好。 我正在使用MIP SDK v1.8.86和.NET Core 3.1。 知道OneDS是什么或者是什么导致了错误吗?

  • 新CONF:我做了一些改变来配合你所说的。现在我删除了hibernate-cfg.xml并在spring-servlet.xml中做了所有的conf: 它可能来自我的java文件吗? 错误是: Bean 类 [org.springframework.orm.hibernate4.LocalSessionFactoryBean] 的属性 'transaction' 无效:Bean 属性 'trans

  • 我有一个应用程序(Spring 4 MVC Hibernate 4 MySQL Maven集成示例使用注释),使用基于注释的配置将Spring与Hibernate集成。 我有这个实体: 和这个: 服务中的这种方法: 在控制器中: 但我得到了这个错误:

  • 我正在使用JPA(Hibernate 4 . 3 . 3作为持久性提供者)和Spring (3.2.2),我所有的字段都加载得很好,但是当我试图访问我的集合时,它抛出了错误- 当我调试这个时,我的实体类中定义的每个集合都有错误- 我尝试使用collection.size()和Hibernate.initialize(),但都不起作用。在Internet上搜索时,我发现扩展Persitence将解决

  • 我的问题与这篇文章有关:Gradle构建在我使用jhipster和Lombok 1.16的Lombok注释类上失败。18岁,身材魁梧。格雷德尔如下 但是在编译Java时得到以下错误: 我错过了什么?