简体   繁体   English

在Watir Webdriver中使用当前保存的Cookie

[英]Use Currently Saved Cookies in Watir Webdriver

Is it possible to use currently saved cookies in Watir Webdriver when launching Chrome? 启动Chrome时,是否可以在Watir Webdriver中使用当前保存的Cookie?

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. 我在登录facebook时将我的镶嵌设置为“记住我”,以便下次访问Facebook时,我不必再次输入用户名和密码。 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. 但是,当使用watir webdriver时,Chrome会像新会话一样打开它并像第一次访问Facebook那样需要我再次输入用户名和密码。 I expected it to directly open facebook without going through the login page again. 我希望它能直接打开facebook,而无需再次浏览登录页面。 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 . 您需要为Chrome创建自定义配置文件 ,根据需要调整其设置,然后通过设置Chrome开关指示Watir使用它。

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

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

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