代码之家  ›  专栏  ›  技术社区  ›  Huy Do

如何在Ruby中为Jenkins服务器上运行的Cucumber设置ChromeDriver路径?

  •  5
  • Huy Do  · 技术社区  · 9 年前

    我使用Cucumber和Capybara在Jenkins服务器上运行自动化测试。Firefox的一切都很好。然而,我在设置Google Chrome和ChromeDriver时遇到了问题。我已经安装了Google Chrome和ChromeDriver(将ChromeDriver移动到usr/bin/ChromeDriver),但当测试运行时,它会通知一个错误:

    "Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver." 
    

    下面是我在环境中的设置。用于Chrome驱动程序的rb:

      Capybara.register_driver :chrome do |app|
        Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches =>
          %w[--ignore-certificate-errors --disable-popup-blocking])
      end
    

    当register_driver时,如何设置ChromeDriver的路径?以前有人经历过这个问题吗? 非常感谢。

    4 回复  |  直到 9 年前
        1
  •  11
  •   Juanma Jurado    8 年前

    对于硒3.x Selenium::WebDriver::Chrome.driver_path = <path to chromedriver> 已弃用 。现在您必须将chrome_driver路径放在驱动程序的声明中:

    Capybara::Selenium::Driver.new(app, :browser => :chrome, :driver_path => <path to chromedriver>)

        2
  •  5
  •   Thomas Walpole    9 年前

    您要么需要将驱动程序置于PATH中,要么应该能够调用

    Selenium::WebDriver::Chrome.driver_path = <path to chromedriver> 
    

    初始化驱动程序之前

        3
  •  -2
  •   S.M.Milon    9 年前

    你必须下载 ChromeDriver 。解压缩文件并将其放在PATH中的任何文件夹中。简而言之,将文件移动到Ruby文件夹,可能是C:\Ruby22-x64\bin

        4
  •  -2
  •   Rashcando    8 年前

    请放置chromedriver。exe位于与ruby.exe相同的文件夹/位置。这对我有用