簡體   English   中英

如何將watir-chrome設置為使用特定配置文件,以便可以使用存儲的Cookie

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

這是我的代碼,我需要使用存儲的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]

嘗試使用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