browser.download.dir无法在selenium web驱动程序中运行 [英] browser.download.dir not working in selenium web driver
问题描述
我使用profile.SetPreference来更改FF的下载目录。我调试它,看到它在代码中正确呈现,但文件未正确保存在该目录中。在此先感谢
I used profile.SetPreference for changing the download directory of the FF. I debugged it and saw that it is rendering properly in code but the file is not properly saved in that directory. Thanks in advance
推荐答案
profile.SetPreference
明确用于配置文件设置修饰符。它会对你有所帮助如果您提供Webdriver,FF驱动程序和浏览器版本,请查找代码问题。
虽然我在代码中使用了以下提供的代码并且已经执行正确。
Selenium版本:3.3.1
操作系统:Win 7 64b
浏览器:Firefox
浏览器版本:53.0.3
//为firefox特定设置创建firefoxprofile
FirefoxProfile profile = new FirefoxProfile();
//设置下载文件夹
profile.setPreference(browser.download。 dir,path / to / folder);
//将文件下载到下载文件夹
profile.setPreference(browser.download .folderList,2);
//下载星时不显示下载窗口ts
profile.setPreference(browser.download.manager.showWhenStarting,False);
//阻止文件下载对话框显示某些MIME类型
profile.setPreference(browser.helperApps.neverAsk.saveToDisk,application / pdf);
is explicitly used for profile setting modifier.It would have been helpful to find the issue with you code if you provide the Webdriver,FF driver and browser versions.
Though I have used the below furnished code in my code and it has been executed properly.
Selenium version: 3.3.1
OS:Win 7 64b
Browser: Firefox
Browser version:53.0.3
// Create a firefoxprofile for firefox specific settings
FirefoxProfile profile = new FirefoxProfile();
// Set the downloads folder
profile.setPreference("browser.download.dir", path/to/folder);
// Download files to the downloads folder
profile.setPreference("browser.download.folderList", 2);
// Don't show downloads window when download starts
profile.setPreference("browser.download.manager.showWhenStarting", False);
// Prevent file download dialog to be shown for certain MIME-types
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf");
这篇关于browser.download.dir无法在selenium web驱动程序中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!