Does anyone provide an example of how to access windows.localStorage using PuppeteerSharp?
There are lots of examples of how to do it using (JS)Puppeteer, but I'm having problems doing it in C#.
As far as I can tell, I need to use EvaluateFunctionAsync
, and do something like the following:
var localStorage = await page.EvaluateFunctionAsync("async () => await window.localStorage");
But this just returns an empty JToken.
Can anyone help me out?
Asked
Active
Viewed 602 times
2

Hoppy
- 720
- 2
- 12
- 24
1 Answers
2
Got it:
var localStorage = await page.EvaluateFunctionAsync<Dictionary<string, string>>("async () => Object.assign({}, window.localStorage)");

Hoppy
- 720
- 2
- 12
- 24