Deleting Cookies

I am doing the web testing with Katalon Studio and I have multiple scenario in my test. Executing these one by one scenario with the same credentials.

After the first completion of the first scenario and trying to logging in for second scenario with the same credentials, the web page says “User already logged in from a different session”. I have used the WebUI.deleteAllCookies() command already and I don’t seems to be working this.

Can you please anyone guide me on this to proceed further ?

So the “User already logged in from a different session” is probably not a cookies issues, its more likely to be a caching issue. Now i dont know how your application works but i assume that when you login it has a token that lasts for x amount of time before the user is automatically logged out of that session.

Really what you need to do is either add a logout step to the end of the first test case so that the session is stopped, or you need to make a change to the application. What i mean is for the dev to add some JS that will automatically clear the cache or change the way your “token” for each session functions. This may be lowering the time of each session.

I guess another solution would be to clear the browser cache but that just seems like uneccessary work when you could just logout.

Hope that makes sense :slight_smile:

Thanks for your quick reply.
Now, I am logging off till the end for the first test case. Can you please share the example adding some JS that will automatically clear the cache or change the way of “token” ?

OR any possibility to use incognito window each time ? if yes, how to add in the settings ?

If logging out at the end of the session doesnt work then, me personally, i would say thats a bug in your application and should be something you relay back to dev. If your logging out then the session token should expire, regardless of how long that token is expected to last.

This is something dev will have to add in the actual application.

Now to do this go to -

Project settings > Desired capabilites > Web Ui > Chrome

Follow this, number 3 shows how to do for incognito

Thanks for your help. You are right. Developing team can change it. But one of their requirement also user should not be logged in less than 5 minutes. In this case, how can we proceed ?

I have tried the above options that you provide. It is not working properly. Can you please provide your further inputs if any ?

This requirement doesnt really make sense to me, i appreciate you might not be English so your trying your best, so thanks. I will just have to go off what i can interpret.

I think what your trying to say is that when a user logs in, that token for the session lasts 5 minutes, regardless of whether or not the user logs out? Now i might have read it wrong so please correct me if i have. If this is the case i would argue this a poor requirement and the session token should end when the user logs out, even if its less than 5 minutes.

Please could you elaborate on whats not working, in essence, the incognito should solve all your problems so a work around till dev either make changes or not would be to get that working :slight_smile:

What I mean to say is it stays the session for 5 minutes. Less than this time, we cannot login again.

And the second one, by adding the incognito window also, the cookies not getting deleted i.e., not opening a new windows. Still we see that already logged error. Please find the attached one.

Now i will say again i dont know your application, this may be needed for security reasons, but if the user logs out, i would have expected that session to be reset, regardless of the length the user was logged in for.

Ok so if we cant change that, then i guess you could add a 5 minute delay onto the end of the test case, that would mean you can ensure the session has expired and the user can then login again. Really im running out of options, if incognito doesnt work, and you cant change the functionality, i can only see this delay as being an option that works

I will ask for some more brains that might have a better solution for you

@Russ_Thomas @Brandon_Hein @kazurayam


(Post must be at least 10 characters - where’s my gun when I need it?)

1 Like

You could also try simply closing the browser and reopening. In the webdriver world, this essentially “clears the cache”, because each instance of the driver technically uses its own profile.

// code to log out
// code to log in

Just out of curiosity, have you run this exact scenario by your developers, and they have confirmed that the 5 minute minimum session time is a requirement? Seems quite odd to me… This would obviously be a severe bottleneck for any automation.

Another idea: Can you just log in as a different user to continue the test?

Totally agree, unless its a security feauture due to the nature of the application, i cant see why you wouldnt want the logout button to kill the session. :thinking:

they have poor infrastructure, so to avoid server overload they put a caching in between :)))
i saw that many times

Thank You All. Appreciate your suggestions :smiley:

Yes… I have confirmed with the developers that they need to have 5 minute time. Another thing is, I will have to use the same user and this user has additional privileges to the application.

I will try your mentioned code i.e., closing the browser and open it.