Prem Sichanugrist
1 min readNov 14, 2016

--

So, it turned out that Rails 5 changed the way you reconstruct the cookie jar. However, I’ve found out the better way to reconstruct the cookie jar … by reconstruct ActionDispatch::Request object instead!

def cookies
ActionDispatch::Request.new(page.driver.request.env).cookie_jar
end

I tested this in Rails 4.2.7.1 and 5.0.0.1 and it worked in both versions. This helper method should be less brittle as the constructor of ActionDispatch::Request is documented (but the CookieJar wasn’t — it was private). I’ve updated the post to use this new method. Let me know if it works for you.

--

--

Prem Sichanugrist
Prem Sichanugrist

Written by Prem Sichanugrist

Senior Developer at Degica. I also contribute to open source projects, mostly in Ruby.

No responses yet