我在Windows计算机上使用latest Selenium独立服务器(3.0.0-beta2)(Windows Server 2012 R2标准版) 已安装Java(java版“1.8.0_101”)。
我正在使用以下命令执行JAR:
java -jar selenium-server-standalone-3.0.0-beta1.jar -port 8888
现在,当我请求http://localhost:8888时,我刚刚收到Jetty的HTTP 404错误:
HTTP ERROR: 404
Problem accessing /. Reason:
Not Found
Powered by Jetty://
端口8888是免费的,任何其他程序都不会使用。
这是我启动服务器时的控制台输出:
11:17:26.292 INFO - Selenium build info: version: '3.0.0-beta1', revision: '8e4315c'
11:17:26.292 INFO - Launching a standalone Selenium Server
2016-08-03 11:17:26.371:INFO::main: Logging initialized @1176ms
11:17:26.542 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:17:26.542 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:17:26.558 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8
2016-08-03 11:17:26.700:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2016-08-03 11:17:26.793:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@6d8a00e3{/,null,AVAILABLE}
2016-08-03 11:17:27.027:INFO:osjs.ServerConnector:main: Started ServerConnector@1d057a39{HTTP/1.1}{0.0.0.0:8888}
2016-08-03 11:17:27.027:INFO:osjs.Server:main: Started @1839ms
11:17:27.043 INFO - Selenium Server is up and running
当尝试实例化RemoteWebDriver(使用.NET API)时,我得到以下异常:
new RemoteWebDriver(new Uri("http://127.0.0.1:8888"), DesiredCapabilities.HtmlUnitWithJavaScript())
WebDriver.dll中发生未处理的“OpenQA.Selenium.WebDriverException”类型异常
其他信息:意外错误。
错误405
HTTP错误:405
访问/会话时出现问题。原因:
HTTP method POST is not supported by this URL
由Jetty提供支持://
答案 0 :(得分:1)
实例化RemoteWebDriver时指定的端点不正确。
请将"http://127.0.0.1:8888"
更改为"http://127.0.0.1:8888/wd/hub"
,然后重试。
http://localhost:8888
给出错误的原因是因为没有定义为默认servlet服务所有端点的默认servlet。这就是
HTTP ERROR: 404
Problem accessing /. Reason:
Not Found
Powered by Jetty://
暗示着。如果是与端口相关的错误,当您尝试启动服务器本身时,您会看到带有JVM_Bind消息的Java错误。
最后,您似乎正在启动selenium服务器,然后使用RemoteWebDriver与之通信。在这种情况下,您没有涉及网格设置的任何特定原因?
如果您打算在另一台计算机上运行您的selenium服务器,并且您的测试是在另一台计算机上分离出来的,那么您应该考虑利用Selenium网格。
如果您在执行测试的同一台机器上运行selenium服务器,那么最好不要跳过使用selenium服务器,而只是直接使用具体的浏览器实现。