You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get Cookies always Returns Empty List using the default Firefox profile #177
*** Testcases ***
Test Browser Should Have Cookies
Open Browser http://www.google.com browser=firefox
${cookies}= Get Cookies
Should Not Be Empty ${cookies}
The default Firefox profile has several privacy settings, like browser.privatebrowsing.autostart, turned on so I wouldn't be surprised that the above test fails. I wouldn't expect any cookies. See the Open Browser keyword for more information about the Firefox profile.
hi, thanks for the reply, are you talking about a default FF profile that's packaged up with Selenium2Library or my own ff profile? If the former, was this setting changed recently? It works on ff 18 :(
Yes, I was talking about the default FF profile within the Selenium2Library. If it works for FF18 and not FF19 the problem might lie within Selenium and not the Selenium2library. You could try to confirm this by creating a selenium only test as outlined here.
thanks! i haven't had a chance to write the test to narrow who the guilty party may be. will let you know...also need to peruse the selenium issues list
Long time and no action, but for what it's worth. If the line: user_pref("browser.privatebrowsing.autostart", true);
is changed to: user_pref("browser.privatebrowsing.autostart", false);
in Selenium2Library/resources/firefoxprofile/prefs.js
it works for me.
Wierd, but Oscarhs solution doesn't work for me :(
Can anybody told me is it an RF or Sel issue or no? So should we expect some new build fith fiz or just leave this and start looking for ... workaround except using coockies ?
I think @oscarh is onto something.
On ESR 24, with browser.privatebrowsing.autostart = true, cookies set with Add Cookie show up in Get Cookies, but other cookies do not.
Here's a test that passes if private browsing autostart is false, but not when it is true:
Open Browser http://www.w3schools.com/js/js_cookies.asp ff
Click Button Create Cookie 1 # this sets a simple, session-only cookie
${cookies}= Get Cookies
Should Contain ${cookies} firstname=John
I noticed that even in the latest release of FF (29), the GCLI/Developer Toolbar (Shift+F2) has a command "cookie list" that will not show cookies that are visible via document.cookie when private browsing. I think the native interface that Selenium uses simply will not work during private browsing except to retrieve cookies set through that same cookie manager.
I think we should stop using private browsing, but set the profile to behave close to it - not remembering forms, deleting history and cookies on exit, etc. Here are the settings I think we should put in place of user_pref("browser.privatebrowsing.autostart", true);.
changed the title [-]Get Cookies Returns Empty List for Firefox 19[/-][+]Get Cookies always Returns Empty List using the default Firefox profile[/+]on Aug 29, 2014
It looks like the capability to access the cookie manager used in private browsing via an API has not been implemented, so I am not going to bother the Selenium developers.
See Mozilla bugs 823941 and 777620
I'm pretty sure my fix works but it is causing failures which are due to Get Cookies not working as described. It uses Selenium's get_cookies to fetch cookies which claims are 'of the current page' but it is not filtering. Chrome and Firefox (when not private browsing) return cookies set on the empty path (host?) as well. The same cookie set for /html is also setting it for /, so in Get Cookie's return value, it shows up twice.
This is not an issue for Get Cookie. In Py and Java, it returns the first cookie with a matching name, and it appears that the cookie for the current page appears before the cookie for an empty path.
All three things below are describing the exact same functionality:
Selenium Py doc for get_cookies: Returns a set of dictionaries, corresponding to cookies visible in the current session.
Selenium doc for GET /session/:sessionId/cookie: Retrieve all cookies visible to the current page.
Selenium Javadoc for getCookies(): Get all the cookies for the current domain. This is the equivalent of calling "document.cookie" and parsing the result
Guess we aren't the only ones keeping the documentation consistent and correct :)
I'm thinking of just changing the documentation for Get Cookies and adjusting the tests to handle the existing behavior.
After executing
Add Cookie test seleniumlibrary
Add Cookie another value
get_cookies is returning this for Chrome and FF (not private browsing):
I am OK with that. Specially if the documentation points to Mozilla doc/bug which explains that in the private browsing one can not access cookies and gives an example ff profile where private browsing is disabled.
Activity
emanlove commentedon Mar 14, 2013
The default Firefox profile has several privacy settings, like browser.privatebrowsing.autostart, turned on so I wouldn't be surprised that the above test fails. I wouldn't expect any cookies. See the Open Browser keyword for more information about the Firefox profile.
butterdave commentedon Mar 14, 2013
hi, thanks for the reply, are you talking about a default FF profile that's packaged up with Selenium2Library or my own ff profile? If the former, was this setting changed recently? It works on ff 18 :(
DP
emanlove commentedon Mar 14, 2013
Yes, I was talking about the default FF profile within the Selenium2Library. If it works for FF18 and not FF19 the problem might lie within Selenium and not the Selenium2library. You could try to confirm this by creating a selenium only test as outlined here.
Sorry I am not much more helpful.
emanlove commentedon Mar 20, 2013
@butterdave For what it is worth our internal tests for cookies are currently failing under Firefox 19
butterdave commentedon Mar 20, 2013
thanks! i haven't had a chance to write the test to narrow who the guilty party may be. will let you know...also need to peruse the selenium issues list
oscarh commentedon Mar 17, 2014
Long time and no action, but for what it's worth. If the line:
user_pref("browser.privatebrowsing.autostart", true);is changed to:
user_pref("browser.privatebrowsing.autostart", false);in Selenium2Library/resources/firefoxprofile/prefs.js
it works for me.
Kristina001 commentedon Jun 18, 2014
Wierd, but Oscarhs solution doesn't work for me :(
Can anybody told me is it an RF or Sel issue or no? So should we expect some new build fith fiz or just leave this and start looking for ... workaround except using coockies ?
ombre42 commentedon Jun 19, 2014
ombre42 commentedon Jun 20, 2014
I noticed that even in the latest release of FF (29), the GCLI/Developer Toolbar (Shift+F2) has a command "cookie list" that will not show cookies that are visible via document.cookie when private browsing. I think the native interface that Selenium uses simply will not work during private browsing except to retrieve cookies set through that same cookie manager.
I think we should stop using private browsing, but set the profile to behave close to it - not remembering forms, deleting history and cookies on exit, etc. Here are the settings I think we should put in place of
user_pref("browser.privatebrowsing.autostart", true);.aaltat commentedon Jun 30, 2014
I have similar problem. I tweaked FF profile:
user_pref("app.update.auto", false); user_pref("app.update.enabled", false); user_pref("browser.preferences.advanced.selectedTabIndex", 3); user_pref("browser.migration.version", 22); user_pref("browser.startup.homepage", "about:blank"); user_pref("browser.tabs.warnOnClose", false); user_pref("network.cookie.prefsMigrated", true); user_pref("privacy.sanitize.migrateFx3Prefs", true)And by this configuration I get the cookies. Could the S2L default profile be updated to allow the Get Cookie* keywords to work.
[-]Get Cookies Returns Empty List for Firefox 19[/-][+]Get Cookies always Returns Empty List using the default Firefox profile[/+]ombre42 commentedon Oct 1, 2014
It looks like the capability to access the cookie manager used in private browsing via an API has not been implemented, so I am not going to bother the Selenium developers.
See Mozilla bugs 823941 and 777620
ombre42 commentedon Oct 4, 2014
I am still working on a fix.
I'm pretty sure my fix works but it is causing failures which are due to
Get Cookiesnot working as described. It uses Selenium'sget_cookiesto fetch cookies which claims are 'of the current page' but it is not filtering. Chrome and Firefox (when not private browsing) return cookies set on the empty path (host?) as well. The same cookie set for /html is also setting it for /, so in Get Cookie's return value, it shows up twice.This is not an issue for
Get Cookie. In Py and Java, it returns the first cookie with a matching name, and it appears that the cookie for the current page appears before the cookie for an empty path.All three things below are describing the exact same functionality:
get_cookies: Returns a set of dictionaries, corresponding to cookies visible in the current session.GET /session/:sessionId/cookie: Retrieve all cookies visible to the current page.getCookies(): Get all the cookies for the current domain. This is the equivalent of calling "document.cookie" and parsing the resultGuess we aren't the only ones keeping the documentation consistent and correct :)
I'm thinking of just changing the documentation for
Get Cookiesand adjusting the tests to handle the existing behavior.After executing
get_cookies is returning this for Chrome and FF (not private browsing):
aaltat commentedon Oct 4, 2014
I am OK with that. Specially if the documentation points to Mozilla doc/bug which explains that in the private browsing one can not access cookies and gives an example ff profile where private browsing is disabled.
andreabisello commentedon Jan 19, 2016
can be for this reason that my website with "remember me" functionality that uses cookies will not work?
i tried to modify
c:\Python27\Lib\site-packages\Selenium2Library\resources\firefoxprofile\prefs.js
adding @oscarh or @aaltat code but i still have the problem : cookies seems not to be stored so "remember me" doesn't works.
aaltat commentedon Jan 19, 2016
No. It is caused in the way selenium works. More details can be found from the answer, to your question, in the user group.