[英]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.我在调试模式下开始测试,我打开了一些服务主页,然后我从 selenium 驱动程序获得了 session_id,并将它与来自浏览器 cookies 的 session 值进行了比较(它是 base64 编码的,所以我解码了它) - 它们是不同的。 May be from articles I understood it wrong, but I thought that cookies should store the session id.可能来自我理解错误的文章,但我认为 cookies 应该存储 session id。 Could someone explain it?有人可以解释一下吗?
You're confusing two different types of sessions.您混淆了两种不同类型的会话。 Basically a session is a system state defined for particular client.基本上 session 是为特定客户端定义的系统 state。 Typically the server stores that state and associates it with some ID.通常服务器会存储 state 并将其与某个 ID 相关联。
So when you have selenium test there are two sessions (at least) in place.因此,当您进行 selenium 测试时,(至少)有两个会话。
A session that is maintained between your test code and WebDriver (which is also a web service).在您的测试代码和 WebDriver 之间维护的 session (这也是一个 web 服务)。 That is one you pick with driver.session_id
.那是你用driver.session_id
选择的。 That session is defined on WebDriver side. session 是在 WebDriver 端定义的。
A session that is maintained in application under test .在被测应用程序中维护的 session 。 This is what you know from cookies put to your browser.这就是你从 cookies 中了解到的内容。
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)虽然 webdriver 上的 session 用于区分和定义 WebDriver 客户端的状态(您可以在多个测试中并行使用相同的驱动程序服务),cookies 中的 session 用于维护应用程序用户 state(通常将浏览器活动与在应用程序)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.