В тестах вы можете использовать gem show_me_the_cookies (обертка / адаптер)
cookies = show_me_the_cookies # => [{:name, :domain, :value, :expires, :path, :secure}]
# here you can write them as you like
# and then load and
cookies.each{|c|
create_cookie(c[:name], c[:value], path: c[:path], domain: c[:domain]) # etc.
}
Без драгоценных камней вы можете напрямую звонить на драйвер селена:
driver = Capybara.current_session.driver # or get your selenium driver other way if not using capybara
cookies = driver.browser.manage.all_cookies
# be sure that you've visited a page in your app, selenium cannot create cookies at `about:blank`
driver.browser.manage.add_cookie(name: ..., value:...)