4
2

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.

unknown error: path is not canonicalを回避した時のメモ

Last updated at Posted at 2016-08-09

ローカルにあるファイルをアップロードするテストで下記のエラーが出た
(firefoxでは出なかったがchromedriverで実行したら出た)

Selenium::WebDriver::Error::UnknownError:
       unknown error: path is not canonical: /Users/username/reponame/../SampleFiles/xxxx.jpg

"path is not canonical"とは「パスの表記が不正」の意味らしい。
この場合は".."の部分があやしい(親のディレクトリを指定する ".."がそのまま文字列認識されている?)と思って、

テスト用ファイルが入っているディレクトリ指定を
↓これから
file_path = File.join(File.dirname(__FILE__), '/../SampleFiles/')

↓こう変えたら
file_path = Pathname(File.dirname(__FILE__)).parent + 'SampleFiles/'

ChromeでもFirefoxでもエラーが出なくなった。

4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?