尝试使用chromedriver

时间:2015-10-05 12:42:46

标签: ruby-on-rails ruby selenium selenium-chromedriver

我正在尝试从ruby控制台调用chrome。

我正在使用命令 - Watir::Browser.new :chrome

我有红宝石 - 红宝石1.9.3p484

我已经安装了宝石, watir-wedriver 的版本是 - watir-webdriver(0.6.11)

chrome的版本是 - 44.0.2403.157

我有chromedriver版本 - v2.9.248304

如果我在这里做错了,有人会指出。不知道该做什么谷歌似乎没有帮助,我是一个新的ruby和脚本。

当我尝试启动chrome时,我收到以下错误 -

Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.9.248304,platform=Linux 3.13.0-32-generic x86_64)

from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/response.rb:71:in `assert_ok'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/http/common.rb:78:in `new'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/http/common.rb:78:in `create_response'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/http/default.rb:90:in `request'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/bridge.rb:657:in `raw_execute'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/bridge.rb:122:in `create_session'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/remote/bridge.rb:87:in `initialize'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/chrome/bridge.rb:48:in `initialize'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/common/driver.rb:56:in `new'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/common/driver.rb:56:in `for'
from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver.rb:86:in `for'
from /var/lib/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/browser.rb:46:in `initialize'
from (irb):3:in `new'
from (irb):3
from /usr/bin/irb:12:in `<main>'irb(main):004:0> 

2 个答案:

答案 0 :(得分:0)

根据您的问题,可能有两个原因

  1. Chromedriver未正确设置在PATH变量OR
  2. 您缺少DISPLAY参数环境变量。
  3. 请仔细阅读这篇文章,了解DISPLAY参数可能对您有所帮助: Selenium web driver DISPLAY variable value

答案 1 :(得分:0)

问题是我的机器没有显示驱动程序所以当我试图运行chrome时它失败了。还有一件事我尝试无头也使用镀铬驱动程序,但问题是我没有足够的权限无头宝石运行。因此,更改权限使我的任务变得简单,现在我可以使用ruby运行selenium脚本。

如果有人对此区域有任何其他疑问,您可以在此向我发送个人信息,或者只是评论此信息会尝试回复。