如何设置watir-chrome以使用特定的配置文件,以便我可以使用存储的cookie

时间:2012-06-29 00:04:54

标签: ruby watir-webdriver selenium-chromedriver

这是我的代码,我需要使用存储的cookie,这样我就可以避免回答随机安全问题。我究竟做错了什么?提前感谢您的建议。

pdate = `/Users/XXXX/lab2/cpb/CBTprevDate.pl`
download_directory = "/Users/XXXX/lab2/cpb"
puts download_directory
profile = Selenium::WebDriver::Chrome::Profile.new
profile['download.prompt_for_download'] = false
profile['download.default_directory'] = download_directory

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 600 # seconds ?~@~S default is 60
b = Watir::Browser.new :chrome, :profile => profile, :http_client => client, :switches => %w[--user-data-dir=/Users/XXXX/lab2/cwm/Default]

1 个答案:

答案 0 :(得分:0)

尝试使用watir-webdriver Cookies API

b.goto 'http://yourwebsite.com'
b.cookies.clear
b.cookies.add 'SESSION', 'value'