1
我試圖運行一個ruby文件,它將啓動使用硒webdriver的chrome驅動程序。我有硒獨立服務器2.35.0。和安裝了chromedriver可執行文件。我通過運行啓動服務器,Selenium Webdriver和Chrome驅動程序 - 無法運行Chrome驅動程序
java -jar ./selenium-server-standalone-2.35.0.jar -Dwebdriver.chrome.bin=/usr/bin/google-chrome -Dwebdriver.chrome.driver=/home/./chromedriver &
兩個會話正在啓動並且chrome驅動程序無法啓動。
05:07:34.328 INFO - Executing: [new session: {platform=ANY, javascriptEnabled=tr
ue, cssSelectorsEnabled=true, browserName=chrome, nativeEvents=false, rotatable=
false, takesScreenshot=false, version=, chrome.switches=[--ignore-certificate-er
rors]}] at URL: /session)
05:07:34.329 INFO - Creating a new session for Capabilities [{platform=ANY, cssS
electorsEnabled=true, javascriptEnabled=true, browserName=chrome, nativeEvents=f
alse, rotatable=false, takesScreenshot=false, chrome.switches=[--ignore-certific
ate-errors], version=}]
Starting ChromeDriver (v2.2) on port 9143
05:07:54.887 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException:
java.lang.reflect.InvocationTargetException
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-38-virtual',
java.version: '1.7.0_25'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSessi
on.java:176)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSessio
n.java:112)
at org.openqa.selenium.remote.server.DefaultSession.createSession(Defaul
tSession.java:89)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(De
faultDriverSessions.java:89)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSessio
n.java:63)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConf
ig.java:205)
at org.openqa.selenium.remote.server.JsonHttpRemoteConfig.handleRequest(
JsonHttpRemoteConfig.java:192)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverS
ervlet.java:201)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.
java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet
.java:139)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.jav
a:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler
.java:677)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.j
ava:568)
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:914)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:9
86)
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:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationT
argetException
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-38-virtual',
java.version: '1.7.0_25'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructo
r(DefaultDriverFactory.java:72)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(De
faultDriverFactory.java:56)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(
DefaultSession.java:215)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(
DefaultSession.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession
.java:169)
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:724)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructo
r(DefaultDriverFactory.java:62)
... 9 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed
to start: exited abnormally
(Driver info: chromedriver=2.2,platform=Linux 3.2.0-38-virtual x86_64) (WARNIN
G: The server did not provide any stacktrace information)
Command duration or timeout: 20.56 seconds
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-38-virtual',
java.version: '1.7.0_25'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.
java:191)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHa
ndler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:554)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriv
er.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.jav
a:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.jav
a:115)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:150)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:129)
... 14 more
05:07:54.889 WARN - Exception: unknown error: Chrome failed to start: exited abn
ormally
(Driver info: chromedriver=2.2,platform=Linux 3.2.0-38-virtual x86_64) (WARNIN
G: The server did not provide any stacktrace information)
Command duration or timeout: 20.56 seconds
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-38-virtual',
java.version: '1.7.0_25'
Driver info: org.openqa.selenium.chrome.ChromeDriver
An error occurred in an after hook
NoMethodError: undefined method `quit' for nil:NilClass
occurred at /home/deploy/deployment/ih2/spec/monitoring_script/NineMonitoring.
rb:24:in `block (2 levels) in <top (required)>'
F
Failures:
1) MonitoringScript test_script
Failure/Error: @driver = Selenium::WebDriver.for(:remote, :url => 'http://
localhost:4444/wd/hub', :desired_capabilities => @caps)
Selenium::WebDriver::Error::UnknownError:
unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.2,platform=Linux 3.2.0-38-virtual x86_64)
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.56 seconds
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:
42:01'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-38-vi
rtual', java.version: '1.7.0_25'
Driver info: org.openqa.selenium.chrome.ChromeDriver (org.openqa.selenium
.WebDriverException)
# [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstruct
orAccessorImpl.java):-2:in `newInstance0'
# [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstruct
orAccessorImpl.java):57:in `newInstance'
# [remote server] sun.reflect.DelegatingConstructorAccessorImpl(DelegatingC
onstructorAccessorImpl.java):45:in `newInstance'
# [remote server] java.lang.reflect.Constructor(Constructor.java):526:in `n
ewInstance'
# [remote server] org.openqa.selenium.remote.ErrorHandler(ErrorHandler.java
):191:in `createThrowable'
# [remote server] org.openqa.selenium.remote.ErrorHandler(ErrorHandler.java
):145:in `throwIfResponseFailed'
# [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDrive
r.java):554:in `execute'
# [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDrive
r.java):216:in `startSession'
# [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDrive
r.java):111:in `<init>'
# [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDrive
r.java):115:in `<init>'
# [remote server] org.openqa.selenium.chrome.ChromeDriver(ChromeDriver.java
):150:in `<init>'
# [remote server] org.openqa.selenium.chrome.ChromeDriver(ChromeDriver.java
):129:in `<init>'
# [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstruct
orAccessorImpl.java):-2:in `newInstance0'
# [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstruct
orAccessorImpl.java):57:in `newInstance'
# [remote server] sun.reflect.DelegatingConstructorAccessorImpl(DelegatingC
onstructorAccessorImpl.java):45:in `newInstance'
# [remote server] java.lang.reflect.Constructor(Constructor.java):526:in `n
ewInstance'
# [remote server] org.openqa.selenium.remote.server.DefaultDriverFactory(De
faultDriverFactory.java):62:in `callConstructor'
# [remote server] org.openqa.selenium.remote.server.DefaultDriverFactory(De
faultDriverFactory.java):56:in `newInstance'
# [remote server] org.openqa.selenium.remote.server.DefaultSession$BrowserC
reator(DefaultSession.java):215:in `call'
# [remote server] org.openqa.selenium.remote.server.DefaultSession$BrowserC
reator(DefaultSession.java):1:in `call'
# [remote server] java.util.concurrent.FutureTask$Sync(FutureTask.java):334
:in `innerRun'
# [remote server] java.util.concurrent.FutureTask(FutureTask.java):166:in `
run'
# [remote server] org.openqa.selenium.remote.server.DefaultSession$1(Defaul
tSession.java):169:in `run'
# [remote server] java.util.concurrent.ThreadPoolExecutor(ThreadPoolExecuto
r.java):1145:in `runWorker'
# [remote server] java.util.concurrent.ThreadPoolExecutor$Worker(ThreadPool
Executor.java):615:in `run'
# [remote server] java.lang.Thread(Thread.java):724:in `run'
# ./NineMonitoring.rb:11:in `block (2 levels) in <top (required)>'
Finished in 20.75 seconds
1 example, 1 failure
Failed examples:
rspec ./filename.rb:28 # filename test_script
這來自我使用運行該文件後
bundle exec rspec filename.rb
我是新來的這一點,並不能找出什麼錯誤。而且我正試圖無頭跑步,所以我有Xvfb運行。有人可以幫助指出我犯的錯誤,並啓動chromedriver?
UPDATE:
的建議後,我已經更新了ChromeDriver並得到以下錯誤:
10:19:44.378 INFO - Executing: [new session: {platform=ANY, javascriptEnabled=tr
ue, cssSelectorsEnabled=true, browserName=chrome, nativeEvents=false, rotatable=
false, takesScreenshot=false, version=, chrome.switches=[--ignore-certificate-er
rors]}] at URL: /session)
10:19:44.417 INFO - Creating a new session for Capabilities [{platform=ANY, cssS
electorsEnabled=true, javascriptEnabled=true, browserName=chrome, nativeEvents=f
alse, rotatable=false, takesScreenshot=false, chrome.switches=[--ignore-certific
ate-errors], version=}]
Starting ChromeDriver (v2.9.248304) on port 21908
[0.723][WARNING]: PAC support disabled because there is no system implementation
An error occurred in an after hook
NoMethodError: undefined method `quit' for nil:NilClass
occurred at /home/deploy/deployment/ih2/spec/monitoring_script/NineMonitoring.
rb:24:in `block (2 levels) in <top (required)>'
While running the file:
Failures:
1) MonitoringScript test_script
Failure/Error: @driver = Selenium::WebDriver.for(:remote, :url => 'http://
localhost:4444/wd/hub', :desired_capabilities => @caps)
Timeout::Error:
Timeout::Error
# ./testfile.rb:11:in `block (2 levels) in <top (required)>'
Finished in 1 minute 0.19031 seconds
1 example, 1 failure
任何人都可以請幫我搞清楚了什麼錯誤?
第一件事是更新Selenium和ChromeDriver:http://docs.seleniumhq.org/download/和http://chromedriver.storage.googleapis.com/index.html ...因爲你大量出來兩者的日期。 – Arran
謝謝阿蘭。但在試驗和探索硒時,我確實有最新版本的硒獨立服務器和鍍鉻驅動器。但它似乎沒有相處。之前,我在降級到硒獨立服務器2.35後成功執行了此文件。現在我已經明白了這個問題。我已將java 1.6.0_27更改爲java 1.7版本。硒和鉻鎳合金似乎不喜歡這種組合。所以我再次嘗試使用最新版本的selenium和chromedriver,但不起作用。現在我想知道如何繼續! – Saran
** Chrome **和** ChromeDriver **以及** Selenium **和** Java **的哪些版本現在*正在運行? – Arran