我已经启动了本地硒服务器,并使其可以与Chrome一起使用,但是由于某种原因,我无法使其与HTMLUnit一起使用(之所以需要它,是因为chrome对于我打算运行的负载来说太重了)。
我像这样启动硒服务器:
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$4 (NewSessionPipeline.java:76)
at java.util.Optional.orElseThrow (Optional.java:408)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$5 (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$0 (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)
答案 0 :(得分:0)
我是如此接近...我要做的就是颠倒类的路径顺序。
java -cp htmlunit-driver-2.33.3-jar-with-dependencies.jar:selenium-server-standalone-3.141.59.jar org.openqa.grid.selenium.GridLauncherV3