我正在尝试运行一个ruby文件,该文件将使用seleniumwebdriver启动chrome驱动程序。我有selenium独立服务器2.35.0。和chromedriver可执行文件已安装。我正在通过运行服务器来启动
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吗?
更新:
根据建议,我已经更新了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
谁能帮我找出问题所在吗?
使用Java 1.6可以达到目的。
在尝试Selenium-server-standalone-2.37.0.jar之后;谷歌浏览器33.0.1750.117;
chromedriver_linux64_2.2; Java版本“ 1.7”,发现Java版本与其他版本不兼容。从而解决了我的问题。
我试图运行一个ruby文件,这将启动chrome驱动程序使用selenium WebDriver。我有selenium独立服务器2.35.0。和chromedriver可执行文件安装。我通过运行来启动服务器, 这是在我使用 我对此很陌生,不知道哪里出了问题。我也试图无头运行它,所以我有Xvfb运行。有人能帮我指出我犯的错误并启动chromedriver吗? 更新: 谁能帮我弄清楚出了什么问题吗?
当我尝试用Selenium 3.14、3.13或3.12启动WebDriver时,我得到 “org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器的地址无效或浏览器启动失败。”错误。 我可以用旧的Selenium版本运行测试而没有错误。我已经设置了环境变量(例如webdriver.chrome.drive
我试图通过TestContainer运行Selenium测试。 这是由于 但是,如果我直接从一个测试调用它,它就会通过并且找到方法,例如。 但是,如果通过类调用此方法,则会抛出 这是我的测试方法: } 此测试从 其中抛出 这是一个演示项目,我已设置尝试和重新创建的问题,这里是我的整个文件:
当我完成自动化后,Chrome Web驱动程序仍在后台运行,是否可以自动关闭它,而无需通过任务管理器执行?
我有这个文件test.py: 我想使用此python代码从页面获取页面源。我使用的是chrome驱动程序selenium和python。但是当我启动这个脚本时,我遇到了这个错误: 我在互联网上尝试了几乎所有的解决方案,但每次我遇到其他错误时,有人知道我在这种情况下应该怎么做吗?有人建议我如何解决这个问题吗?
我试图运行一个项目在硒与铬驱动程序,但我没有使用它一个月后(是一个更新到铬)。当我运行这个项目时,它会打开浏览器,然后立即关闭。 我收到以下错误: Traceback(最近一次调用最后一次):文件"C:\用户\maorb\OneDrive\Desktop\Maor\python\serethd\tvil_arthur.py",第27行,在驱动程序=webDrive中。Chrome()File"C: