Clearing cache for each login

Hello all , need some inputs.
I have a scenario where I have to login as 3 different users in one testcase . Because of cache when I login as second user it is displaying the functionalities of first user.

Scenario:

  1. Login as user1 , logout from user1
    2.In the same browser ,reload the page with passing URL, Login as user2 , logout from user2 and same for user3

can you gups please suggest on how to proceed on this.

Logout and then use keyword as below:

I tried Delete All Cookies keyword but its seems that it is not working.
image

Maybe the following will aid your test:

Thank you @grylion54 . we currently have issues with incognito. once it resolved I will try on that part.

hi @kharitha17

what shows the first user’s features after re-login is almost never the http cache, it is web storage. the app keeps the session or the permissions in localStorage / sessionStorage (and sometimes indexeddb), and deleteAllCookies does not touch those. clear them explicitly after logout, while you are still on the app’s origin:

WebUI.deleteAllCookies()
WebUI.executeJavaScript('window.localStorage.clear(); window.sessionStorage.clear();', null)
WebUI.executeJavaScript('''
  if (indexedDB.databases) indexedDB.databases().then(dbs => dbs.forEach(d => indexedDB.deleteDatabase(d.name)))
''', null)
WebUI.navigateToUrl(GlobalVariable.url)

then log in as user 2. if the app also caches the user profile in a service worker, add navigator.serviceWorker.getRegistrations().then(r => r.forEach(x => x.unregister())) to that script.

the other clean option is a new browser per user: closeBrowser then openBrowser again gives you a brand new temporary profile with nothing in it. that also answers your invalid session id thread, after closeBrowser every stored driver reference is dead, so call WebUI.openBrowser(‘’) again and get the driver fresh via DriverFactory.getWebDriver() instead of reusing a variable from before the close.

Good diagnosis, web storage is the likely culprit here. A few additions:

  1. IndexedDB deletion and service worker unregistering are async, so add a short WebUI.delay(1) before navigateToUrl, or the cleanup can be cut off mid-way.
  2. deleteAllCookies only clears the current domain. If login goes through SSO on another domain (Okta, Azure AD, etc.), that IdP session survives and user1 gets silently logged back in. Clear that domain too, or use a new browser per user.
  3. Cache Storage is separate from the stores above: caches.keys().then(k => k.forEach(c => caches.delete(c))).
  4. Closing and reopening the browser per user is the most reliable option, so I’d use it unless the test needs one window.
  5. If a fresh browser still shows user1’s data, logout isn’t invalidating the session server-side. That’s an app bug to raise with dev.