简体   繁体   中英

Use Currently Saved Cookies in Watir Webdriver

Is it possible to use currently saved cookies in Watir Webdriver when launching Chrome?

I set my chrome to "remember me" when login to facebook so that the next time I access facebook, I don't have to type the username and password again. But, when using watir webdriver, the Chrome will open it like new session and accessing facebook like the first time which requires me to type the username and password again. I expected it to directly open facebook without going through the login page again. Is there a way to do that?

Thank you very much.

You need to create a custom profile for Chrome, adjust its settings as desired, then direct Watir to use it by setting the Chrome switches .

args = ['--user-data-dir=/path/to/your/custom/profile']
Watir::Browser.new :chrome, options: {args: args}

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