jf003
jf003

Reputation: 13

How to retrieve session from a previous test and inject session variables as a part of url path

I'm trying to write acceptance tests with codeception.

I made a first acceptance test that loads a page with a comparison of products.

I save session snapshot with $I->saveSessionSnapshot('Comparison');

In a second test, I want to continue from this page Comparison.

In the beginning of this second test, I wrote: $I->loadSessionSnapshot('Comparison');

But, after that, I need to write: $I->amOnPage('/comparison/{userToken}');

The user token is in the session, in a variable userToken that I would like to inject in my url.

How can I do that?

Upvotes: 1

Views: 133

Answers (1)

Naktibalda
Naktibalda

Reputation: 14110

You can't do that.

Session snapshot doesn't mean snapshot of server side session, it is a snapshot of browser session and it actually stores all cookies.

If it was a functional test, you could implement some way to directly access session storage based on session id, but in acceptance test you have no direct access to server side code or storage.

It would be better to modify your application code to read userToken from session when it isn't specified in the URL, then you could use $I->amOnPage('/comparison/'); in the test.

Upvotes: 3

Related Questions