- Posted by Intent Media
- 1 Comments
One of the many useful features of Selenium WebDriver is that it can act as a wrapper for several different browser drivers. This means (in theory, at least) that if you restrict yourself to calling methods exposed by the WebDriver API, you can reuse the same code to drive automated tests in any of the browsers WebDriver supports.
In practice, however, this is not always the case. There can be subtle differences in how WebDriver’s methods are implemented for each browser. In some cases, certain browsers may not support a given method at all.
One example is deleting cookies. In Ruby, we can tell WebDriver to delete all cookies for the current domain via a call to
This executes WebDriver’s browser-specific implementation of the delete_all_cookies method, which for most browsers works as expected.
For Safari, a message is passed to the SafariDriver telling it to execute its own cookie deletion method. In OSX, SafariDriver does this by deleting the ~/Library/Cookies/Cookies.binarycookies file where the cookie data is stored.
Unfortunately, as of Safari 6.0, cookie data is also stored in active memory by the cookied process. If cookied notices that Cookies.binarycookies is missing, it simply recreates the file from memory — … Continue reading