On any page (class) of a page, you can define a method that processes cookies and accesses them using PageObject. There are several ways to implement a PageObject, depending on what other structures you use, but here is an example of using IRB.
Example IRB:
>> require "watir-webdriver" >> require "page-object" >> @browser = Watir::Browser.start "http://stackoverflow.com" >> my_page = MyPage.new(@browser) >> @cookies_to_keep = my_page.get_cookies_as_array
The original cookies are restored with their original: name and: value.
The Docs API Justin Ko pointed you to is a very valuable link.
source share