Posted over 8 years ago
Can't delete cookies with Cucumber, Capybara, and Selenium
I ran into an interesting selenium bug that prevented me from deleting authentication cookies.
The use case I was attempting to recreate was logging into my application (with oath against google), logging out, then logging in as a different user.
With open auth, as long as you are logged in to the oath provider, you do not need to re-authenticate with the provider to authenticate with the client site. So, I needed to sign out of the oauth provider’s site before re-authenticating.
I attempted to use Selenium to delete the cookies to simulate the sign out. The issue was that when I tried to delete the goggle authentication cookies, nothing appeared to happen and I would remain authenticated with the provider.
It turns out that there exists a such a thing as ‘invisible cookies.’ Selenium can not see these cookies unless you are actually on the site that uses them (i.e the oath provider).
To resolve the issue I used selenium to visit the providers site (google in my case) before issuing the selenium command to delete the cookies.
I’m curious if anyone has found another solution to this issue that would allow me to sign out of the providers site without actually visiting the site? Please comment if you find a better approach.