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?
Got it:
var localStorage = await page.EvaluateFunctionAsync<Dictionary<string, string>>("async () => Object.assign({}, window.localStorage)");