Browser SessionStorage

Class library usage, coding and language questions.
Posts: 19
Joined: Thu Mar 21, 2019 2:43 pm

Browser SessionStorage

Post by mafi » Thu Mar 03, 2022 2:22 pm

Is there anybody know how to get info from browser SessionStorage using C# code into Ranorex?
I would need some information present in the current browser "Window.SessionStorage", but I am not able to get them except using browser devtools console.
I tried to google it, but I found only few indication about httpcontex method of System.Web namespace, but I am not able to get that package using nuget and so I have not been able to further investigate.
Is there anyboy here could help me in this?
Thank you in advance.

Posts: 16
Joined: Mon Jan 17, 2022 12:10 pm

Re: Browser SessionStorage

Post by csaszi89 » Mon Apr 25, 2022 11:13 am

Hi mafi,

how about calling some javascript via your WebDocument?

Code: Select all

var repo = yourAppRepository.Instance;
var webDocument = repo.yourApp.Self;
string script = "sessionStorage.setItem('myKey', 'myValue');"; // script to add value to the storage
script = "return sessionStorage.getItem('myKey');"; // script to get value from the storage
string value = webDocument.ExecuteScript(script);
Report.Info(value); // myValue
Let's give it a try!