![](/img/trans.png)
[英]Using watir-webdriver to set cookies on internet explorer
[英]Unable to set download directory path with Firefox using Watir-Webdriver
使用时无法设置自定义下载目录路径
Selenium Webdriver 3.3.0
Watir-Webdriver 0.9.9
Firefox 52 , geckodriver 0.15
Windows 7, Ruby 2.1.9
代码看起来像这样。
EXPORTS_DIR = 'exports'
EXPORTS_PATH_BROWSER = File.realpath(EXPORTS_DIR)
firefox_profile = Selenium::WebDriver::Firefox::Profile.new
firefox_profile['browser.download.dir'] = EXPORTS_PATH_BROWSER
firefox_profile['browser.download.animateNotifications'] = false
firefox_profile['browser.download.panel.shown'] = false
firefox_profile['browser.download.useDownloadDir'] = true
FIREFOX_CAPS = Selenium::WebDriver::Remote::Capabilities.firefox(
firefoxOptions: {
args: ['--always-authorize-plugins'],
prefs: firefox_profile
}
)
browser = Watir::Browser.new( firefox:, desired_capabilities: FIREFOX_CAPS)
我得到对话框来保存/打开我不想要的文件,并且文件未下载。 所以有两个问题
除了提及要使用哪个文件夹下载外,您还需要告诉Firefox它需要使用自定义下载位置。 您可以使用以下代码进行操作:-
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = download_dir
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.