简体   繁体   English

如何在Watir中设置cookie

[英]How to set cookies in Watir

I have to scrap a site using Watir and Chrome browser. 我必须使用Watir和Chrome浏览器废弃网站。 The site needs multiple location selectors to open. 该站点需要多个位置选择器才能打开。 I need to set the location parameters in the cookie. 我需要在cookie中设置位置参数。

I have used the method listed in this URL: http://watir.com/guides/cookies/ 我使用了此URL中列出的方法: http//watir.com/guides/cookies/

On running the code I got the following error: Failed to set the 'cookie' property on 'Document': Cookies are disabled inside 'data:' URLs. 在运行代码时,我收到以下错误:无法在'Document'上设置'cookie'属性:在'data:'URL中禁用Cookie。 (Selenium::WebDriver::Error::NoScriptResultError) (硒:: webdriver的::错误:: NoScriptResultError)

browser.cookies.add 'foo', 'bar', path: '/', expires: 10.days.from_now, secure: true

参考: Watir

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

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