Link to home
Start Free TrialLog in
Avatar of satmisha
satmishaFlag for India

asked on

Login and logout with different user credentials

Hi experts,

Using;
Selenium, Chrome Browser, C#, nUnit:

My scenario is ::
1. I need to login to my application ( chrome browser), process Test Case.
2. Logout, close browser window
3. Open new chrome window.
4. Re-launch the browser with the same URL
5. Login again with different user6. process test cases
6. Logout.

What I am doing:
When I close browser and launched new URL and tries to login with different credentials I get the below error:

Problem:
Getting this exception:
"invalid session id\n  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64)"

Please help.
Avatar of Steve
Steve
Flag of United Kingdom of Great Britain and Northern Ireland image

check the url you're opening initially. it may contain session info if it was bookmarked/copied when logged in with the first user.
Avatar of satmisha

ASKER

Thanks steve, I have checked that and URL appears to me normal, I have hardcoded that for the time being indeed which is same.
As Steve suggests, session info is somehow following you.

Glancing at the docs (I only took a few minutes) I'm missing how the default cookie file is handled.

My guess is you're defaulting to use some common cookie file, rather than creating a new/random/unique cookie file for each session.

Try creating a /tmp cookie file made up of procname + pid + username + 16byte random alphanumeric string, then destroy this file when you exit.

This should at least fix any carry over session problems.
Thanks David, providing little more details:

[TestMethod]
public void ClickingAllTheEnglishPageLinks() // Starting the automation framework from the main
{
	Driver = new ChromeDriver();
	Implicitlywait();
	Driver.Navigate().GoToUrl(websiteUrl);
	Driver.Manage().Window.Maximize();

	LoginWithUserA();
	Driver.CloseBrowser();
	
	LoginWithUserB();
	 /*********getting this exception, moment click on Login Button****
	 Problem: 
	Getting this exception: 
	"invalid session id\n  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64)"
	*************************************************************************************************************/
}

Open in new window


What I am doing in the above case, unable to understand?
ASKER CERTIFIED SOLUTION
Avatar of satmisha
satmisha
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial