我尝试按照Wiki页面中列出的步骤解决我的问题,并在与Selenium服务器运行phantomjs时使用github.com/theintern/intern-examples/phantomjs-example。虽然我仍然收到此错误:
$ ./node_modules/.bin/intern-runner config=tests/intern
Listening on 0.0.0.0:9000
Starting tunnel...
UnknownError: [POST http://localhost:4444/wd/hub/session /
{"desiredCapabilities":
{"browserName":"phantomjs","name":"tests/intern","idle-timeout":60}
}]
org.openqa.selenium.browserlaunchers.Proxies
at Server._post <node_modules\intern\node_modules\leadfoot\Server.js:68:9>
at Server.createSession <node_modules\intern\node_modules\leadfoot\Server.js:282:15>
at Suite.setup <node_modules\intern\runner.js:208:22>
at callOnSuite <node_modules\intern\lib\Suite.js:131:42>
at call <node_modules\intern\lib\Suite.js:182:13>
at Suite.run <node_modules\intern\lib\Suite.js:269:4>
at <node_modules\intern\main.js:48:18>
at <node_modules\intern\lib\util.js:324:19>
at Array.forEach <native>
at Object.run <node_modules\intern\main.js:47:16>
TOTAL: tested 0 platforms, 0/0 tests failed; fatal error occurred
其他人遇到同样的问题并知道如何解决?
来自Wiki的说明:
environments: [ { browserName: 'phantomjs' } ]
和tunnel: 'NullTunnel'
npm install -g phantomjs
安装,通常就是这种情况)(java -jar selenium-server-standalone-2.xx.x.jar)
intern-runner config=path/to/config
我使用的所有文件:https://github.com/theintern/intern-examples/tree/master/phantomjs-example
Selenium服务器错误日志
$ java -jar selenium-server-standalone-2.44.0.jar
13:05:37.261 INFO - Launching a standalone server
13:05:38.251 INFO - Java: Oracle Corporation 25.25-b02
13:05:38.251 INFO - OS: Windows 7 6.1 amd64
13:05:38.265 INFO - v2.44.0, with Core v2.44.0. Built from revision 76d78cf
13:05:38.402 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
13:05:38.403 INFO - Version Jetty/5.1.x
13:05:38.405 INFO - Started HttpContext[/selenium-server,/selenium-server]
13:05:39.348 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@6e3c1e69
13:05:39.349 INFO - Started HttpContext[/wd,/wd]
13:05:39.349 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
13:05:39.350 INFO - Started HttpContext[/,/]
13:05:39.355 INFO - Started SocketListener on 0.0.0.0:4444
13:05:39.356 INFO - Started org.openqa.jetty.jetty.Server@b1bc7ed
13:05:59.689 INFO - Executing: [new session: Capabilities [{name=tests/intern, browserName=phantomjs, idle-timeout=60}]])
13:05:59.707 INFO - Creating a new session for Capabilities [{name=tests/intern, browserName=phantomjs, idle-timeout=60}]
13:05:59.720 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'VM-C02JQ1VTDKQ4', ip: '127.0.0.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_25'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:175)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:111)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:88)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:108)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:112)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:172)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:201)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:163)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:129)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'VM-C02JQ1VTDKQ4', ip: '127.0.0.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_25'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:69)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:53)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:54)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:214)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:168)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:59)
... 9 more
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/browserlaunchers/Proxies
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:178)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
... 14 more
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.browserlaunchers.Proxies
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
13:05:59.936 WARN - Exception: org.openqa.selenium.browserlaunchers.Proxies
答案 0 :(得分:4)
PhantomJS是broken with Selenium 2.44.0 now too。
最佳解决方案:停止使用PhantomJS!
替代解决方案:只要使用PhantomJS补丁,就会使用Selenium 2.43或更早版本。
答案 1 :(得分:1)
PhantomJS与Selenium 2.45配合使用
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>