WebDriverError:找不到文件

时间:2017-08-17 23:26:44

标签: selenium-webdriver webdriver

我收到此Selenium WebDriver错误:

WebDriverError: File not found: /Users/foo/bar/nabisco/cdt-now/csv-data/IT-DE-Yasper.csv
事实是,这个文件完全存在于文件系统中。 selenium服务器在本地运行。所以我不确定为什么它找不到该文件。有人知道吗?

1 个答案:

答案 0 :(得分:1)

如果使用Firefox 55,即使文件存在,最近的错误也会导致发生此异常。 请参阅https://github.com/mozilla/geckodriver/issues/858

在修复错误之前,有一种解决方法:将Firefox首选项“dom.file.createInChild”设置为“true”。

例如:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("dom.file.createInChild", true);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(capabilities);