我想使用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的下載位置?