Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor: clear browsing data completely

I'm looking for a way to completely delete all cookies, session/state cookies, storage, etc. using Protractor. Basically, I want to accomplish the same thing in Protractor as a user would by going to Settings -> Clear browsing data.

browser.manage().deleteAllCookies() does not delete httpOnly cookies. And since JavaScript can't touch httpOnly cookies, I can't use JavaScript.

I know I could restart the browser in Protractor, but prefer not to go this route.

Any suggestions?

like image 856
mws Avatar asked Oct 28 '16 00:10

mws


1 Answers

This answer by Anthony Panozzo was the best way for me to clear session and local storage (https://stackoverflow.com/a/25678498/5072980)

afterEach(function() {
  browser.executeScript('window.sessionStorage.clear();');
  browser.executeScript('window.localStorage.clear();');
});
like image 129
Jason Evans Avatar answered Sep 21 '22 09:09

Jason Evans