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."
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
});
May be you want to empty browser's local storage?
afterEach(function() {
browser.executeScript('window.sessionStorage.clear();');
browser.executeScript('window.localStorage.clear();');
});`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With