Protractor: clear browsing data completely

偶尔善良 提交于 2020-01-01 10:29:42

问题


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?


回答1:


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();');
});


来源:https://stackoverflow.com/questions/40296093/protractor-clear-browsing-data-completely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!