Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

session_id from selenium driver and session value from browser cookie are different values

I started test in debug mode where I opened some service main page, then I got session_id from selenium driver and compared it with session value from browser cookies (it was base64 encoded, so I decoded it) – they are different. May be from articles I understood it wrong, but I thought that cookies should store the session id. Could someone explain it?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You’re confusing two different types of sessions. Basically a session is a system state defined for particular client. Typically the server stores that state and associates it with some ID.

So when you have selenium test there are two sessions (at least) in place.

  1. A session that is maintained between your test code and WebDriver (which is also a web service). That is one you pick with driver.session_id. That session is defined on WebDriver side.

  2. A session that is maintained in application under test. This is what you know from cookies put to your browser.

So they are not the same. While session on webdriver serves to distinguish and define states of WebDriver clients (you can use the same driver service in parallel with multiple tests) the session in cookies serves for maintaining the application user state (usually associate a browser activity with a user registered in the app)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading