user1314404
user1314404

Reputation: 1305

How can I stop user session data from being transferred between new tabs or windows in Chrome?

I am using ChromeDriver to make POST requests to an API for auto-login and to open a website. What I’ve noticed is that when I run it with two different accounts, the website opens in two separate tabs, each logged in with a different user. However, if I click on the username in the tab that was opened first, it immediately switches to display the information of the second user (the account that logged in later).

This creates an issue: if I need to perform actions on both accounts, I can only complete the process for the first account once because subsequent actions will switch from the second account to the first one. Strangely, this behavior isn’t consistent. Sometimes it happens, but other times it works as expected. From my observations, it seems that if the time gap between the two actions is longer, the session might time out, and the issue doesn’t occur. On the other hand, if the actions are performed too close together, the session data from the first account persists and gets passed to the next call, causing it to process on the first account instead of the second.

I need to perform these two actions simultaneously. How can I prevent this issue so both accounts can remain logged in and process independently? My initial thought is to use normal Chrome mode for one account and incognito mode for the other. Would that resolve the problem?

Thank you very much for your advice!

Upvotes: 0

Views: 20

Answers (0)

Related Questions