Unable to Set Session Data in ATF

sonaligchav
Tera Contributor

I'm trying to set session data using gs.getSession().putClientData("Code", "00000") in ATF. I tried two approaches:

  • Using a Script Test Step in ATF.
  • Calling a Script Include that uses putClientData() from ATF.

In both cases, when I use getClientData() to verify, it returns null. The integration works fine outside ATF. Is there a limitation with session data in ATF? Should I use user preferences instead?
Any best practices or alternatives would be appreciated. 

3 REPLIES 3

Shaqeel
Mega Sage

Hi @sonaligchav 

 

In ATF, gs.getSession().putClientData() and getClientData() dont behave the same wqay they do in normal interactive user session because in ATF server side test steps run in a headless stateless session.

Session data like putClientData() is tied to be real user's HTTP session, which ATF does not persist between steps in the same way as a live UI. This is why getClientData() always returns null during run.

Best practice:

Store your values in a sys_user_preference record for the test user during execution.

Create custom table for temporary test data and read/write.

 

Regards

Shaql


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

Ankur Bawiskar
Tera Patron
Tera Patron

@sonaligchav 

what's your business requirement to store those?

session data cannot be used with ATF.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Basically we need session based login in our custom service portal , for that we authenticate based on session as which user is logged to. So in ATF when I tried to set a session in step1  via script include or server script step and tried to impersonate and login to service portal, it shows access denied as it is unable to read the session from the session in step1.

Can you please help with this use case.