我试图开始使用硒。
我用sudo npm install selenium-standalone@latest -g
安装了它。然后我用sudo apt-get install default-jre
安装了Java。命令java -version
现在说:
java version "1.7.0_101"
OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-0ubuntu0.15.10.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
最后用sudo selenium-standalone install
完成了selenium安装。当我现在尝试使用命令selenium-standalone start
启动Selenium时,我收到以下消息:
14:40:31.337 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to /usr/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.21-x64-chromedriver
14:40:31.357 INFO - Java: Oracle Corporation 24.95-b01
14:40:31.357 INFO - OS: Linux 4.2.0-34-generic amd64
14:40:31.364 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
14:40:31.406 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform LINUX
14:40:31.406 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, browserName=MicrosoftEdge, version=}] does not match the current platform LINUX
14:40:31.406 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:40:31.406 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
14:40:31.407 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{platform=MAC, browserName=safari, version=}] does not match the current platform LINUX
14:40:31.407 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
14:40:31.408 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
14:40:31.441 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
14:40:31.441 INFO - Selenium Server is up and running
Selenium started
我并不关心丢失的Firefox和Internet Explorer驱动程序,因为我试图将Selenium与Chromium一起使用。
如果我现在将Chromium指向:http://127.0.0.1:4444/wd/hub
,我会看到一个网页,其中包含一个空的会话列表和一个按钮"创建会话"。如果我点击该按钮并选择" Chrome"作为我的浏览器,我在控制台上收到错误Unable to create new sesssion
和以下消息:
14:48:08.866 INFO - Executing: [new session: Capabilities [{browserName=chrome}]])
14:48:08.867 INFO - Creating a new session for Capabilities [{browserName=chrome}]
Starting ChromeDriver 2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a) on port 16552
Only local connections are allowed.
14:48:10.094 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'beetlejuice', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-34-generic', java.version: '1.7.0_101'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
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.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'beetlejuice', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-34-generic', java.version: '1.7.0_101'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
... 9 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome version must be >= 46.0.2490.0
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 4.2.0-34-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.21 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'beetlejuice', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-34-generic', java.version: '1.7.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
... 14 more
14:48:10.096 WARN - Exception: unknown error: Chrome version must be >= 46.0.2490.0
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 4.2.0-34-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.21 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'beetlejuice', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-34-generic', java.version: '1.7.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
然后我尝试运行基于jasmine的测试,但在控制台上产生大致相同的消息。有趣的是,茉莉花确实推出了Chromium,但立即关闭了它。
我的Chromium版本为Version 50.0.2661.102 Ubuntu 15.10 (64-bit)
。
有什么想法吗?