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?
CodePudding user response:
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.
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.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)