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

有人能解释下面的错误吗?并提供解决方案

林泰平
2023-03-14

当我尝试运行时,出现以下错误:

org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'HO00060LP417', ip: '10.14.10.157', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: unknown
Command duration or timeout: 406 milliseconds

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:122)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at com.alfains.automationsuite.testNGTest1.beforeTest(testNGTest1.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.TestRunner.beforeRun(TestRunner.java:626)
at org.testng.TestRunner.run(TestRunner.java:594)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)

原因:org.openqa.selenium.SessionNotCreatedException:无法创建新服务:ChromeDriverService构建信息:版本:“3.141.59”,修订:“e82be7d358”,时间:“2018-11-14T08:25:53”系统信息:主机:“HO00060LP417”,ip:“10.14.10.157”,os.name:“Windows 10”,os.arch:“x86”,os.version:“10.0”,java.version:'1.8.0_111'驱动程序信息:Driver.version:未知生成信息:version:'3.14.0',revision:'aaccce0',time:'2018-08-02T20:19:58.91Z'系统信息:主机:'HO00060LP417',ip:'10.14.10.157',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_60'

Driver info: driver.version: unknown
    at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.lambda$get$0(ServicedSession.java:135)
    at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.apply(ServicedSession.java:152)
    at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$12(ActiveSessionFactory.java:180)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$11$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.server.ActiveSessionFactory.apply(ActiveSessionFactory.java:183)
    at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$2(NewSessionPipeline.java:66)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.util.Collections$2.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$3(NewSessionPipeline.java:69)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.DistinctOps$1$2.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Unknown Source)
    at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:72)
    at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:65)
    at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:235)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

共有1个答案

戚峻
2023-03-14

它说你的驱动程序版本未知。可能找不到chrome驱动程序,或者您使用的chromedriver.exe版本与您安装的chrome版本不兼容。

要启动节点,需要告诉jar chromedriver在该机器上的位置。差不多

java -Dwebdriver.chrome.driver="C:\Users\xxxx\Documents\Browsers\ChromeDirectory\chromedriver.exe" -jar selenium-server-standalone-3.8.1.jar -role node -hub "http://xx.xxx.xx.xxx:4444/grid/register/" -nodeConfig config.json

在代码中尝试这样的内容:

if (Utilities.Browser == "Chrome")
    {
        ChromeOptions options = new ChromeOptions();
        options.AddArgument("disable-extension");
        options.AddAdditionalCapability("useAutomationExtension", false);
        if (Utilities.useSeleniumGrid == "true")
            {
                if (headless)
                {
                    options.AddArgument("no-sandbox");
                    options.AddArgument("headless");
                }
                _currentWebDriver = new RemoteWebDriver(new Uri(Utilities.SeleniumHub), options.ToCapabilities(), TimeSpan.FromMinutes(3));
            }
            else
            {
                _currentWebDriver = new ChromeDriver(chromePath, options);
            }
        }
 类似资料:
  • 我想写一个brainfuck口译员,但我错过了一些上下文或其他东西。应该被调用以处理“

  • 我是Hibernate和JPA的新手,我对这个注释有问题。有人能简单地解释一下这个注释到底在做什么吗?因为在这种情况下,文档对我来说很难理解。 编辑我明白什么是持久上下文,但在代码中,我有这样的例子: 我对@PerustenceContext做什么有问题。抱歉,也许我没有具体说明。

  • 错误 第6:44行:在函数“app”中调用React Hook“useState”,该函数既不是React函数组件,也不是自定义React Hook函数React Hook/rules of Hook 搜索关键字以了解有关每个错误的更多信息。

  • 抱歉,这是一个非常广泛的问题。 下面的代码是在网上找到的东西的片段。我感兴趣的关键是@protected开头的一行——我想知道这是做什么的,它是如何做到的?在执行do_upload_ajax函数之前,它似乎正在检查有效用户是否登录。这看起来是一种非常有效的用户身份验证方法。不过,我不明白这个@函数的机制——有人能告诉我正确的方向,解释一下这将如何在现实世界中实现吗?Python 3请回答。谢谢。

  • 日安, 我有一个问题,在我的代码中,一个声明在函数之外有一个错误。 谢谢