Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to clear the cache, cookies and local storage in protractor. I already tried cleaning local and session storage, it's not working in my case. I want to execute the ctrl+shift+delete using the protractor script only. #5369

Open
pareekniks opened this issue Dec 4, 2019 · 3 comments

Comments

@pareekniks
Copy link

pareekniks commented Dec 4, 2019

How to clear the cache, cookies and local storage in protractor. I already tried cleaning local and session storage, it's not working in my case. I want to execute the ctrl+shift+delete using the protractor script only.

Below code using in after each function but not achieved the required solution.

afterEach( async function () {

await browser.manage().deleteAllCookies();

await browser.executeScript("window.sessionStorage.clear()");

await browser.executeScript("window.localStorage.clear()");

await browser.actions().sendKeys(protractor.Key.CONTROL+protractor.Key.SHIFT+ protractor.Key.DELETE).perform();

Can anyone suggest some solution over this?
Any other solution, which clears the SSO login details.

@CusHoria
Copy link

CusHoria commented Dec 4, 2019

Try to use CTRL + F5 by actions

browser.actions().keyDown(protractor.Key.CONTROL).sendKeys(protractor.Key.F5).perform();

@pareekniks
Copy link
Author

Try to use CTRL + F5 by actions

browser.actions().keyDown(protractor.Key.CONTROL).sendKeys(protractor.Key.F5).perform();

Not working, still the last user data preserved.

@JulienBier
Copy link

In our tests, we succeed to clear the localstorage with this syntax:

afterEach((done) => {
	setTimeout(() => {
		browser.executeScript('window.localStorage.clear();');
		done();
	}, 250);
});

We had to add a timeout to ensure that the localstorage can be cleared by the browser.

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants