SOLUTION/WORKAROUND: See SafariBugWorkaround.java
in this gist for a solution to the problem. Feel free to test it yourself by running TestDriverCookieDeletion.java
with the substitute method.
I've filed the following bug at Apple Feedback Assistant: https://feedbackassistant.apple.com/feedback/6935056
SafariDriver does not delete cookies when the WebDriver driver.manage().deleteAllCookies()
gets called.
Specifically, in the Selenium Java client the method call would be: driver.manage().deleteAllCookies(); // WebDriver.Options::deleteAllCookies;
For a short, self contained, correct (compilable) example, see this Github Gist: https://gist.github.com/gwpantazes/3bc7af273bd80695383c40c90c3938d7 . The example compares behavior of Chrome, Firefox, and Safari. Safari fails to delete the cookies, while the other browsers completely delete the cookie list as expected.
Steps to reproduce: (The following steps are done through scripting in order to hit SafariDriver)
- Start a SafariDriver instance
- Navigate to https://www.apple.com
- Check all current cookies (notice there are some cookies)
- Use the WebDriver to delete all cookies (driver.manage().deleteAllCookies() in Java Selenium Client)
- Check all current cookies again. Observe that cookies are still there; the cookies were not deleted.
Expected Result: The cookies would all be deleted.
Actual Result: All the cookies are still there.
Related issues elsewhere:
- This issue was closed because Apple maintains SafariDriver SeleniumHQ/selenium#1196 (and its duplicate, SeleniumHQ/selenium-google-code-issue-archive#5212 )
- MacOS Mojave 10.14.5 (18F132)
- Safari Version 12.1.1 (14607.2.6.1.1) (and corresponding SafariDriver)