对于 chrome 使用 w3c:true 时无法创建会话错误

问题描述 投票:0回答:2

问题/目标
当启动我的量角器测试时,我得到一个

Unable to create sessions error
。经过无数个小时的调试后,我能够将其范围缩小到量角器配置中的一个选项,
w3c
。当我将
w3c
设置为
true
时,WebDriver 就能够创建会话。如果我将其设置为
false
,则会收到以下错误。

版本

  • MacOS:
    Big Sur - Version 11.6.1
  • 铬:
    96.0.4664.55 (Official Build) (x86_64)
  • 节点:
    10.13.0
  • NPM:
    6.14.15
  • 量角器:
    7.0.0
  • 网络驱动程序管理器:
    12.1.8
  • selenium-webdriver:
    3.6.0
  • 硒独立:
    6.15.1
  • chromedriver(从 webdriver-manager 下载并解压):
    chromedriver_96.0.4664.45

Selenium WebDriver 日志

[15:24:47] I/start - java -Dwebdriver.chrome.driver=/Users/mma3083/Projects/protractor-tests/node_modules/webdriver-manager/selenium/chromedriver_96.0.4664.45 -Dwebdriver.gecko.driver=/Users/mma3083/Projects/protractor-tests/node_modules/webdriver-manager/selenium/geckodriver-v0.30.0 -jar /Users/mma3083/Projects/protractor-tests/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar -port 4446
[15:24:47] I/start - seleniumProcess.pid: 13774
15:24:47.546 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
15:24:47.592 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4446
2021-11-19 15:24:47.625:INFO::main: Logging initialized @214ms to org.seleniumhq.jetty9.util.log.StdErrLog
15:24:47.773 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
15:24:47.841 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4446
15:25:34.784 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "chromeOptions": {
    "args": [
      "--disableChecks",
      "--window-size=1920,1080",
      "--test-type",
      "--disable-software-rasterizer",
      "--mute-audio"
    ]
  },
  "count": 1,
  "goog:chromeOptions": {
    "w3c": false,
    "prefs": {
      "plugins.always_open_pdf_externally": true,
      "download": {
        "prompt_for_download": false,
        "directory_upgrade": true,
        "default_directory": "\u002fUsers\u002fmma3083\u002fProjects\u002fprotractor-tests\u002fdata\u002factualPdfs\u002fmain"
      }
    }
  },
  "loggingPrefs": {
    "browser": "SEVERE",
    "driver": "OFF",
    "performance": "ALL",
    "server": "OFF"
  },
  "maxInstances": 1,
  "shardTestFiles": true,
  "verboseMultiSessions": true
}
15:25:34.785 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}) on port 15153
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1637353536.979][WARNING]: Ignoring unrecognized log type: server
15:25:38.359 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
15:25:38.545 WARN [RemoteSession$Factory.performHandshake] - size = 2
java.lang.IllegalStateException: size = 2
        at net.bytebuddy.matcher.FilterableList$AbstractBase.getOnly(FilterableList.java:108)
        at net.bytebuddy.implementation.InvocationHandlerAdapter.apply(InvocationHandlerAdapter.java:220)
        at net.bytebuddy.implementation.InvocationHandlerAdapter$ForInstance$Appender.apply(InvocationHandlerAdapter.java:341)
        at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyCode(TypeWriter.java:622)
        at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyBody(TypeWriter.java:611)
        at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod.apply(TypeWriter.java:528)
        at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForCreation.create(TypeWriter.java:4167)
        at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:1653)
        at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:183)
        at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:163)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:2669)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:2771)
        at org.openqa.selenium.remote.Augmenter.performAugmentation(Augmenter.java:144)
        at org.openqa.selenium.remote.Augmenter.create(Augmenter.java:63)
        at org.openqa.selenium.remote.BaseAugmenter.augment(BaseAugmenter.java:100)
        at org.openqa.selenium.grid.session.remote.RemoteSession.<init>(RemoteSession.java:92)
        at org.openqa.selenium.grid.session.remote.ServicedSession.<init>(ServicedSession.java:62)
        at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.newActiveSession(ServicedSession.java:177)
        at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.newActiveSession(ServicedSession.java:88)
        at org.openqa.selenium.grid.session.remote.RemoteSession$Factory.performHandshake(RemoteSession.java:168)
        at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.apply(ServicedSession.java:161)
        at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$12(ActiveSessionFactory.java:180)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:1002)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
        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.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.Collections$2.tryAdvance(Collections.java:4853)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
        at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$3(NewSessionPipeline.java:69)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:174)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
        at java.base/java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:720)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
        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.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

量角器日志

[14:40:15] E/launcher - SessionNotCreatedError: Unable to create session from {
  "desiredCapabilities": {
    "verboseMultiSessions": true,
    "goog:chromeOptions": {
      "w3c": false,
      "prefs": {
        "plugins.always_open_pdf_externally": true,
        "download": {
          "prompt_for_download": false,
          "directory_upgrade": true,
          "default_directory": "\u002fUsers\u002fmma3083\u002fProjects\u002fprotractor-tests\u002fdata\u002factualPdfs\u002fmain"
        }
      }
    },
    "count": 1,
    "loggingPrefs": {
      "driver": "OFF",
      "server": "OFF",
      "browser": "SEVERE",
      "performance": "ALL"
    },
    "browserName": "chrome",
    "chromeOptions": {
      "args": [
        "--disableChecks",
        "--window-size=1920,1080",
        "--test-type",
        "--disable-software-rasterizer",
        "--mute-audio"
      ]
    },
    "maxInstances": 1,
    "shardTestFiles": true
  },
  "capabilities": {
    "firstMatch": [
      {
        "browserName": "chrome",
        "goog:chromeOptions": {
          "w3c": false,
          "prefs": {
            "plugins.always_open_pdf_externally": true,
            "download": {
              "prompt_for_download": false,
              "directory_upgrade": true,
              "default_directory": "\u002fUsers\u002fmma3083\u002fProjects\u002fprotractor-tests\u002fdata\u002factualPdfs\u002fmain"
            }
          }
        }
      }
    ]
  }
}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'MMA3083M1', ip: 'fe80:0:0:0:824:4d23:c4c:9e64%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.6.1', java.version: '17.0.1'
Driver info: driver.version: unknown
    at Object.checkLegacyResponse (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
    at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
    at Function.createSession (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at Function.createSession (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
    at createDriver (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
    at Hosted.getNewDriver (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
    at Runner.createBrowser (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/built/runner.js:195:43)
    at q.then.then (/Users/mma3083/Projects/protractor-tests/node_modules/protractor/built/runner.js:339:29)
    at _fulfilled (/Users/mma3083/Projects/protractor-tests/node_modules/q/q.js:834:54)
    at /Users/mma3083/Projects/protractor-tests/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/mma3083/Projects/protractor-tests/node_modules/q/q.js:796:13)
    at /Users/mma3083/Projects/protractor-tests/node_modules/q/q.js:556:49
    at runSingle (/Users/mma3083/Projects/protractor-tests/node_modules/q/q.js:137:13)
    at flush (/Users/mma3083/Projects/protractor-tests/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
[14:40:15] E/launcher - Process exited with error code 199
typescript macos selenium google-chrome protractor
2个回答
2
投票

想通了。

我使用的是 Java 17。降级到 Java 11 (

brew install openjdk@11
),一切都运行良好。


0
投票

Windows 和 selemium 3,使用 https://learn.microsoft.com/en-gb/java/openjdk/download#openjdk-11

我一直在尝试使用 jdk21 - 但不起作用

© www.soinside.com 2019 - 2024. All rights reserved.