简体   繁体   English

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

[英]How do I set watir-chrome to use a specific profile so I can use stored cookies

This is my code, I need to use a stored cookie so I can avoid having to answer random security questions. 这是我的代码,我需要使用存储的cookie,以便避免不得不回答随机安全性问题。 What am I doing wrong? 我究竟做错了什么? Thanks in advance for advise. 在此先感谢您的建议。

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]

Try using watir-webdriver Cookies API 尝试使用watir-webdriver Cookies API

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM