简体   繁体   中英

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. 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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