1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

webdriver-seleniumを使った時に、webdriverのpathが見つからないと言われる。

Posted at

windows7で、webdriver-seleniumのgemを2.53.1にバージョンアップすると
Selenium::WebDriver::Error::WebDriverError: Unable to find the chromedriver executable
とのエラーが出るように。

PATHの確認

今まで動いていたので問題なし

ソースの確認

lib/selenium/webdriver/common/platform.rb
def find_binary(*binary_names)
  paths = ENV['PATH'].split(File::PATH_SEPARATOR)
  binary_names.map! { |n| "#{n}.exe" } if windows?

  binary_names.each do |binary_name|
  paths.each do |path|
    exe = Dir.glob(File.join(path, binary_name)).first
    next unless exe
      return exe if File.executable?(exe)
    end
  end
  nil
end

以前は、環境変数のPATHをたどったとこに、ちゃんとファイルがあるかどうかを確認してなかったのですが、
今回のバージョンでは、ちゃんと確認している。

exe = Dir.glob(File.join(path, binary_name)).first
next unless exe

これが原因で、私のケースでは、PATHをC:¥webdriver_pathのようにしてたため、C:¥webdriver_path/chromedriver.exeのように、¥とスラッシュが混在していたためか、globで取得してくれませんでした。

解決法

環境変数にて、webdriverのPATHを¥からスラッシュ(/)に変更しました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?