我在写Ruby脚本来下载文件使用的Watir网络驱动程序文件的列表自动化。任何指针或自动化膨化接近了窗口和目录选择的保存文件到一个位置?谢谢你。
I'm writing Ruby script to automate Downloading files from a list of files using Watir web driver. Any pointers or approaches on Automating Popping up of Window and Directory Chooser to save the file into a location? Thanks.
推荐答案更改默认的Watir preferences下载位置
change default Watir preferences for download location
铬
profile = Selenium::WebDriver::Chrome::Profile.new download_dir = File.join(Rails.root, 'lib', 'assets') profile['download.default_directory'] = download_dir profile['download.prompt_for_download'] = false @b = Watir::Browser.new :chrome, :profile => profile针对Firefox
for firefox
profile = Selenium::WebDriver::Firefox::Profile.new download_dir = File.join(Rails.root, 'lib', 'assets') profile['browser.download.dir'] = download_dir profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv,application/pdf" @b = Watir::Browser.new. :firefox, :profile => profile请注意:要能够从你的Rails应用程序内方便地访问Rails.root / lib文件夹,你需要这样code或类似的东西添加到您的config / application.rb中的文件:
note: to be be able to access the Rails.root/lib folder easily from within your rails app, you'll need to add this code or something like it to your config/application.rb file:
config.autoload_paths += Dir["#{config.root}/lib/**/"]了解更多信息: watirwebdriver/browser-downloads/
更多推荐
网络的Watir驱动程序下载文件
发布评论