Reputation: 31
I need to open a new web driver after every describe (e2e test i run)
The reason is that i need to clear my browser cache (not cookies),
Every time i try to use ptor.quit()
/ browser.driver.quit()
, i get this exception:
"Error: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used."
Upvotes: 3
Views: 6598
Reputation: 6962
You shouldn't start new webDriver session after each describe
, but in turn use afterAll()
functionality that Jasmine provides which runs after all specs in describe are finished running. In other words afterAll()
runs after each describe and will suffice your need. Do not quit after all your specs are completed in a describe as it stops the webdriver execution itself. Here's how to do it -
afterAll(function() {
browser.executeScript('window.sessionStorage.clear();'); //clear session
browser.executeScript('window.localStorage.clear();'); //clear local storage
});
Upvotes: 3
Reputation: 55
May be you want to empty browser's local storage?
afterEach(function() {
browser.executeScript('window.sessionStorage.clear();');
browser.executeScript('window.localStorage.clear();');
});`
Upvotes: 2