![](/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.