Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Can't add cookie on Chrome Browser through Selenium Webdriver #2835

Closed
lukeis opened this issue Mar 3, 2016 · 4 comments
Closed

Can't add cookie on Chrome Browser through Selenium Webdriver #2835

lukeis opened this issue Mar 3, 2016 · 4 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2835

Hello

I'm using Ruby/Capybara/Cucumber and Selenium Webdriver to control Chrome Browser,
but add_cookie does not work.

Ruby code :
browser = Capybara.current_session.driver.browser
browser.manage.add_cookie :name => "cookie_name", :value => "cookie_value"

The cookie should be set but it doesn't.
I get this error on the console :

Internal Chrome error during 'SetCookie': (Could not set the cookie). Request details:
({"command":"SetCookie","cookie":{"na
me":"cookie_name","path":"/","secure":false,"value":"cookie_value"},"url":"about:blank"}).
(Selenium::WebDriver::Error::UnhandledError)

OS : Windows XP SP3 x86
Browser: Google Chrome 15.0.874.120 m
GEMs :
Using selenium-webdriver (2.12.2)
Using capybara (1.1.1)
Using gherkin (2.6.4)
Using cucumber (1.1.2)
Using rspec-core (2.7.1)
Using rspec-expectations (2.7.0)
Using rspec-mocks (2.7.0)
Using rspec (2.7.0)


Reported by geoffroy.montel.ml on 2011-11-14 13:21:05

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2011-11-14 17:51:19

  • Labels added: Component-WebDriver, Browser-Chrome

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

We don't support adding cookies to "about:blank". You need to be on the actual domain
you want to add the cookie  to.

Reported by jari.bakken on 2011-11-14 18:18:35

  • Status changed: WorkingAsIntended

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Wooops. Thanks a lot. For those who encounter the problem, you have to visit the URL
you want to store the cookie at before. 
In capybara, do that :
visit('/')
browser = Capybara.current_session.driver.browser
browser.manage.add_cookie :name => "cookie_name", :value => "cookie_value"


Reported by geoffroy.montel.ml on 2011-11-15 13:06:35

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:14:09

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant