0

Trying to test some user permissions here, and i'm having trouble logging out after each test...

afterEach: function () {
    return this.remote
    .clearLocalStorage()
  //  .clearCookies();
  },
nextTest: function () {
    return this.remote.get("/")...

This will only work if I clearCookies as well, but I shouldn't need to clear cookies (manually executing localStorage.clear() and reloading works). I would expect return this.remote.clearLocalStorage(); to suffice, but on the following test I get redirected to my dashboard.

erikdstock
  • 1,117
  • 9
  • 16

1 Answers1

0

clearLocalStorage simply sends a DELETE request to the WebDriver server's local_storage endpoint, so the driver is what actually implements the clearing behavior. It's possible that different WebDrivers handle clearing local storage in different ways, but given that local storage and cookie storage are not the same, clearing one shouldn't necessarily affect the other.

jason0x43
  • 3,363
  • 1
  • 16
  • 15
  • Thanks- I eventually learned that clearing both was in fact necessary with the framework we are using, but the above script is still pretty flaky, briefly showing login at route and then redirecting back to the dashboard ... if i add a `.sleep(200)` after `.clearCookies()` it moves from ~5% of tests to almost half. This is with chromedriver so i would expect it to behave predictably and for intern to wait for afterEach's returned promise to resolve. No? – erikdstock Apr 20 '16 at 15:44