-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capybara.reset_sessions! doesn't clear cookies. #535
Comments
I'm also seeing this issue with the same selenium-webdriver and capybara for firefox 7 on a mac |
Yeah forgot to mention, mine is Firefox 7.0.1 as well. |
Could you try updating to the latest selenium-webdriver and see if the issue persists? |
Yes, problem still persists with selenium-webdriver 2.12.2. |
Very odd, I can't replicate this, can you provide a repeatable test case that fails for you, and I will try and see if it breaks for me as well? |
I will try to over the weekend. Thanks. |
The latest webdriver does delete all cookies. However, I noticed that for webdriver doesn't detect all cookies, which gave me the impression that #delete_all_cookies doesn't work. @uahmed you may want to check that you're not running into the same issue. Seems the issues I have now are more with selenium webdriver + firefox itself |
@cldwalker do you mean it works for you with latest release of selenium web driver? The problem as I described was always with selenium + firefox. |
Yes, the latest selenium + firefox 7 works in that the driver deletes On Fri, Nov 18, 2011 at 7:12 PM, Usman Ahmed
|
Okay, Kindly post a link here after you file the bug with selenium. Thanks |
Since this is a Selenium issue, I will close it here. |
Why would reset_sessions reset the cookies also? Cookies != Sessions. What if I want to just reset my session but not my cookies to simulate a browser window being closed and then reopen. You would need to do this to test a cart or login persistance across multiple sessions of the app within the same browser? |
I would just like to add that there are other cases where you can't clear all the cookies by directly using Capybara.reset_session! If you're authenticating against an OAuth provider such as Facebook, Google, Twitter, etc. you need to first visit their respective website and while there you should call Capybara.reset_session! since there are some "invisible" cookies which can only be cleared with Capybara.reset_session! while on the OAuth provider's website (no idea why). It doesn't look like a Capybara issue, not sure if it's a driver issue (tried both with Selenium and Webkit drivers, same result) but I spent a few hours pulling my hair on this. I hope I save you precious hours of your life with this and it'd be great if someone could explain more about why this happens at all. I found about this here: http://www.glennposton.com/posts/cant_delete_cookies_with_cucumber_capybara_and_selenium |
like @mgogov I would also like to add another case that have similar symptoms as this bug (user is not logged out between scenarios). Namely the case where the web app is using HTML5 local storage instead of ordinary cookies to store sessions. In such case there is another bug for that situation: #1001 |
reset_session! : "Reset sessions, cleaning out the pool of sessions. This will remove any session information such as cookies." I on the other hand is looking for a way to clear the session and not the cookies. |
@espen Adding a request for how to do something to an issue that was closed over 2 years ago is unlikely to get you help. Try posting to the mailing list as indicated in the README |
Was mainly just wanting to clarify what the code does as this issue was the first result on Google. I did however find a solution to my problem using this gem which clears expired cookies include session cookie but keeps other cookies. https://github.com/nruth/show_me_the_cookies |
Ran into this issue, after all this time. As @mgogov mentioned, you must visit the site to access the cookie for that site, before calling For my use case, it looks like:
|
@georgeu2000's point seems very important and fixed the problem for us. Could that be documented somewhere? |
@georgeu2000 The behavior is driver dependent - selenium only allowa to clear cookies for the current domain, other drivers allow to just clear all cookies IIRC. Therefore this should not be documented in Capybara.reset_session!. Not sure where would be correct currently though. Maybe just a gotchas section in the README |
This is part of the webdriver spec, unfortunately. So this definitely occurs for all drivers using Selenium's W3C bridge. We might want to consider navigating to Capybara's Here is a similar discussion on the cypress repo: cypress-io/cypress#408 |
I am using Capybara with selenium driver, and doing require 'capybara/cucumber' to reset my session after every scenario. I am running tests in FireFox.
If I debug I can trace that after every scenario Capybara calls the Capybara.reset_sessions! in After do hook, which further down calls @browser.manage.delete_all_cookies in selenium/driver.rb. However it doesn't seem to actually clear the cookies and no exception is thrown as well.
Could this be because Capybara doesn't launch FireFox with Administrator privilege? or there is something else wrong, any ideas?
OS: Windows 7 64 bit.
My gem versions
The text was updated successfully, but these errors were encountered: