March 1, 2023
Not too long ago I ran into a scenario where a test that I was composing needed to make an API call. The challenge was that one of the values needed for an API call was being stored in the browser's session. The tool I was using didn't support directly accessing the browser session. This post describes how I leveraged a combination of TestArchitect capabilities to achieve accessing the browsers session storage. Currently, LogiGear's TestArchitect (TA) doesn't contain any native keyword commands that would allow users to access values stored in the browsers local and session storage. Fortunately, the building blocks are there so this is what I did:
Here's a sample from JSFiddle:
After getting the value out of local storage, the script stores the value in an attribute on the body tag. I made a custom action so that I could access any value from local storage as well as make it easy to reuse. Here's what the final custom action looked like:
Notice the JavaScript we drafted is on line 11 and subsequently injected and executed on line 17. Lastly, once we have extracted the value (line 24) we delete the attribute as it is no longer needed. Here is a sample call to the custom action, the session variable is stored in retValue. From there, you can do whatever you want with it, including passing it to an API call; which is what set me on this adventure to begin with.
This post illustrates how we were able to extend capabilities by utilizing a custom action that could be used in numerous tests. Custom actions are a good way to encapsulate complex operations into a simple, easy to use keyword.
Happy testing!