网络的Watir驱动程序下载文件

编程入门 行业动态 更新时间:2024-10-09 01:21:38
本文介绍了网络的Watir驱动程序下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在写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驱动程序下载文件

本文发布于:2023-11-27 16:19:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序下载   文件   网络   Watir

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!