Selenium 服务器无法与 HTMLUnit 创建会话

Selenium server unable to create session with HTMLUnit

我已经启动了一个本地 selenium 服务器,并让它与 Chrome 一起工作,但出于某种原因我无法让它与 HTMLUnit 一起工作(我需要它,因为 chrome 对于加载我打算 运行).

我这样启动 selenium 服务器:

java -jar selenium-server-standalone-3.141.59.jar

但我也尝试过这个(因为我不太确定对 htmlunit 驱动程序的依赖性应该如何工作)。无论哪种方式,都给出相同的结果:

java -cp selenium-server-standalone-3.141.59.jar:htmlunit-driver-2.33.3-jar-with-dependencies.jar org.openqa.grid.selenium.GridLauncherV3

我使用 python 绑定:

self.driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.HTMLUNITWITHJS)

我得到的错误是:

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create session from {
  "desiredCapabilities": {
    "browserName": "htmlunit",
    "javascriptEnabled": true,
    "version": "firefox",
    "platform": "ANY"
  },
  "capabilities": {
    "firstMatch": [
      {
        "browserName": "htmlunit"
      },
      {
        "browserName": "htmlunit",
        "browserVersion": "firefox",
        "platformName": "any"
      }
    ]
  }
}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '...', ip: 'fe80:0:0:0:1ce9:33:4280:d3bd%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.3', java.version: '11.0.1'
Driver info: driver.version: unknown
Stacktrace:
    at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null (NewSessionPipeline.java:76)
    at java.util.Optional.orElseThrow (Optional.java:408)
    at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession (NewSessionPipeline.java:75)
    at java.util.Optional.orElseGet (Optional.java:369)
    at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession (NewSessionPipeline.java:73)
    at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute (BeginSession.java:65)
    at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle[=13=] (WebDriverServlet.java:235)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
    at java.lang.Thread.run (Thread.java:834)

我太接近了...我所要做的就是颠倒 class 路径顺序。

java -cp htmlunit-driver-2.33.3-jar-with-dependencies.jar:selenium-server-standalone-3.141.59.jar org.openqa.grid.selenium.GridLauncherV3