问题
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