我想使用Watir Webdriver从页面下载文件。我需要能够将下载位置设置为我定义的目录。我发现this page,但那里的代码无法正常工作:使用Watir Webdriver下载文件
profile = Selenium::WebDriver::Chrome::Profile.new
profile['download.prompt_for_download'] = false
profile['download.default_directory'] = download_directory
b = Watir::Browser.new :chrome, :profile => profile
(其中download_directory只是我的桌面)给出了这样的:
Selenium::WebDriver::Error::UnknownError: unknown error: cannot parse capability: chromeOptions
from unknown error: unrecognized chrome option: profile
(Driver info: chromedriver=2.19.346063 (38b35413bd4a486d436a9749e090454bc9ff6708),platform=Mac OS X 10.11.0 x86_64)
from /Users/myusername/.rvm/gems/ruby-1.9.3-p551/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok'
我猜的代码是为老版本的的Watir。如何通过Watir设置Chrome的下载位置?