【问题标题】:Selenium/Watir can't detect Chromedriver, even though it's in my path (Windows 7)Selenium/Watir 无法检测到 Chromedriver,即使它在我的路径中(Windows 7)
【发布时间】:2014-11-14 01:11:31
【问题描述】:

我知道还有一个与此类似的问题,但回答者提供的链接已过时(当我深入研究当前的 Watir 文档时,我只能找到有关 Windows 8.1 的信息;我在 Windows 7 上,步骤该文档建议解决此问题对以下内容没有帮助)

我正在尝试使用 Watir/minitest 执行测试(沿着 rake ci:setup:minitest test TEST=test/full_path/happypath_test.rb 的行),但它在以下情况下窒息:

Selenium::WebDriver::Error::WebDriverError: Unable to find the chromedriver exec
utable. Please download the server from http://chromedriver.storage.googleapis.c
om/index.html and place it somewhere on your PATH. More info at http://code.goog
le.com/p/selenium/wiki/ChromeDriver.

Watir 文档和错误消息都指向 PATH。但是,我刚刚下载了最新版本的 Chromedriver(出现了 2.12)并将 exe 放入了一个我已经确认在我的 PATH 中的文件夹中(特别是 c:/Ruby193/bin - 是的,我知道我在一个旧的Ruby 版本;可惜我不能为这个项目更新)

我知道 Chromedriver 存在,因为我可以从 irb 运行它:

require 'watir-webdriver

紧随其后

b = Watir::Browser.new :chrome

这会启动一个 chrome 窗口。但是当我实际尝试执行测试时,它会给出“找不到 chromedriver”错误。

我已经运行了 bundle install 来尝试确保我使用了正确的版本并且不知道还能做什么。请帮忙?

【问题讨论】:

    标签: selenium watir selenium-chromedriver


    【解决方案1】:

    driver_path 直接指定给 Selenium。

    在启动新的浏览器窗口之前调用它:

    Selenium::WebDriver::Chrome::Service.driver_path = "/absolute/path/to/chromedriver"
    

    这还有一个好处是不需要你弄乱你的PATH,你可以将它签入你的仓库(当然,使路径动态到你的项目根目录等)。

    【讨论】:

      【解决方案2】:

      我发现 herehere 的帖子非常好。您可以通过超级简单的步骤进行配置。

      我已经尝试过并测试过工作出色。

      来自帖子 1: 从 firefox 更改为 chrome(无论您在哪里实例化了浏览器),这样它就会变成: @browser = Watir::Browser.new :chrome

      现在,如果你在 Windows 上,将下载的二进制文件复制粘贴到 C:/Windows 目录中`

      第二篇文章讲述了如何将默认路径 c:\windows 更改为项目的自定义路径。它有趣且乐于助人。一定要看看。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-29
        • 2016-07-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多