Reputation: 1010
I'm using capybara with capybara-webkit for testing, but I need to set some specific cookies.
I'm so confused by it's document, and the source code.
I did find a method here https://github.com/thoughtbot/capybara-webkit/blob/e6e2351a15cabf620152eb938e5cacb514fe1529/lib/capybara/webkit/browser.rb#L177
But I really don't know what format should I use for the 'cookie' param in this method.
If I have a cookie in json like this:
[
{
"domain": ".github.com",
"expirationDate": 1453495731,
"hostOnly": false,
"httpOnly": false,
"name": "__utma",
"path": "/",
"secure": false,
"session": false,
"storeId": "0",
"value": "58162108.1841781874.1390418256.1390423639.1390423639.1",
"id": 1
},
{
"domain": ".github.com",
"expirationDate": 1406191731,
"hostOnly": false,
"httpOnly": false,
"name": "__utmz",
"path": "/",
"secure": false,
"session": false,
"storeId": "0",
"value": "58162108.1390423639.1.1.utmcsr=developer.github.com|utmccn=(referral)|utmcmd=referral|utmcct=/",
"id": 3
},
... ...
]
How to modify the above into the correct acceptable string format for capybara-webkit? Can anyone give me an example?
Upvotes: 0
Views: 1681
Reputation: 2732
The set_cookie
method expects a valid value for the Cookie
header as specified by RFC 2109.
The simplest value would be cookie_name=cookie_value
. You can add other properties with a string like cookie_name=value; domain=example.com; path=/
.
Upvotes: 3