Eric Bellamy
Eric Bellamy

Reputation: 37

How to load cookies before visiting webpage in Watir

So I know I can load cookies in Watir from a file using:

browser.cookies.load("cookies")

The problem is that this will only load cookies for the page I am currently on. So if I want to load the cookies for a webpage I have to visit it before doing so. Is there any way to load cookies before you visit the page?

Upvotes: 2

Views: 457

Answers (1)

titusfortner
titusfortner

Reputation: 4194

Watir mimics what a user can do on a browser. A user must be on a page to load cookies for it, so also does Watir/Selenium. You would need to go to the site, load the cookies then you can refresh page / navigate to where on the site you need to be.

Upvotes: 2

Related Questions