How to get all cookies from a new instance of Firefox browser

Using the following to create the firefox driver

profile = Selenium::WebDriver::Firefox::Profile.new
profile['general.useragent.override'] = agent
browser = Watir::Browser.new :firefox, profile: profile

      

Executing the request: -

broswer.goto "http://goo.gl/QFsO6R"

      

Its redirecting to the amazon site and getting the cookie value from the amazon site.

But I want to get the cookies of this page ( http://goo.gl/QFsO6R ) that is loaded. How can I get it.

To get cookies I use the following: -

browser.cookies.to_a

browser.driver.manage.all_cookies

      

If you are making a request with three different urls using firefox profile. Then I want to get all the cookies stored in the browser. How can I get it?

+3


source to share


2 answers


If you want to get the name of all cookies on the page, use the all_cookies method:



driver.manage.all_cookies.each do |cookie|
    puts cookie[:name]
end

      

0


source


For security reasons, you can only access the cookies set by your site / current page. You cannot access all the cookies stored in your browser.



0


source







All Articles