How to check the location of download folder programmatically in browsers like Safari, Firefox etc on Mac?

你说的曾经没有我的故事 提交于 2019-12-25 18:14:55

问题


I am a part of Automation testing and I am downloading and installing the files programmatically with Selenium and Applescript on Mac. Is their any way to check the location of download folder on browsers programmatically?? if so pls suggest and also ways to change the location of download folder in Java or Applescript.


回答1:


Safari has a preference for it in ~/Library/Preferences/com.apple.Safari.plist:

defaults read com.apple.Safari DownloadsPath

You can also change it by modifying the property list, but the changes aren't applied until Safari is reopened.

defaults write com.apple.Safari DownloadsPath "~/Desktop"



回答2:


may be you can try like this on firefox:

profile = Selenium::WebDriver::Firefox::Profile.new

profile['browser.download.dir'] = "/tmp/webdriver-downloads"

profile['browser.download.folderList'] = 2

profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf"

b = Watir::Browser.new :firefox, :profile => profile



来源:https://stackoverflow.com/questions/13006607/how-to-check-the-location-of-download-folder-programmatically-in-browsers-like-s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!