Let’s say you have a simple SaaS application with a setup that starts a browser and logs in. Towards the end of the test, the cleanup logs the user out, so the next test will run on time. But something goes wrong, and
The simple answer for this in FireFox and Chrome is to driver.quit at the end of each test. The new session will lose all the cookies. You might, however, not want to pay the cost of shutting down and restarting the browser. In that case, you could use the driver.clear_all_cookies() method.
That works fine for the
For those devices, things aren’t nearly as straightforward.
As of this publication, with sample code in ruby, those commands simply don’t work for Edge or Internet Explorer. Neither do the commands to get the cookies - see this in the call to all_cookies in the same code gmail_login_windows.rb. We may explore cookies through
Alternatives Under Windows
Today we’ll provide two examples. For internet explorer, consider shelling out to the command line to remove cookies:
system(“RunDll32.exe InetCpl.cp,ClearMyTracksByProcess 2”);
For Edge, the simplest way is to go into browser settings, delete cookies, then click the button to clear the elements every time the browser quits.
It may also be possible to use the registry editor to delete cookies. Likewise, the example above uses some explicit waits, because the implicit waits fail. To earn some reputation, check some code into
Another alternative, of course, let someone else figure it out renting the web browser used for testing. For now, though, here’s how to do it yourself.