0

这是我的代码,我需要使用存储的 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]
4

1 回答 1

0

尝试使用 watir-webdriver Cookies API

b.goto 'http://yourwebsite.com'
b.cookies.clear
b.cookies.add 'SESSION', 'value'
于 2012-06-29T08:38:31.847 回答