Ajeesh
Ajeesh

Reputation: 37

Serenity session variable usage

Hi team am new to serenity. Let's say am storing this data as follows

Serenity.setSessionVariable("User Name").to("userKey");

Now in a scenario if I call this key like this Serenity.sessionVariableCalled("userKey") from a different step definition in a different class will I get the value saved?.

Upvotes: -1

Views: 7680

Answers (3)

Pr0d1
Pr0d1

Reputation: 1

You can use the Actor specific session data explained in the Serenity user manual here: https://serenity-bdd.github.io/docs/screenplay/screenplay_fundamentals#actor-specific-session-data

Or you can use the old fashion way(explained for an earlier Serenity version in the author's framework blog website: https://johnfergusonsmart.com/sharing-state-steps-serenity-bdd/).

I'm not sure this last approach is still working though(it is a very old Serenity version which is described in this blog post: v1.5.5).

Upvotes: 0

xPlauNx
xPlauNx

Reputation: 11

if it is a scenario different from which you call the session variable, it is not possible. the scenarios are independent -> SOLID

Upvotes: 1

Deep Extreme
Deep Extreme

Reputation: 11

It should return that object, but you may need to typecast it. Also Serenity.sessionVariableCalled("userKey") is calling return (T) getCurrentSession().get("objectKey")

Upvotes: 0

Related Questions