3

I am using puppeteer to take a screen grab. To load the required page however, a context needs to be set in the SessionStorage (of the browser page). I am not able to do achieve that as of now. Any help would be appreciated!.

browser.newPage().then(Page => { //maybe set some context here so that the page can access the context from sessionStorage page.goto(url).then( .....)})

AnweshCR7
  • 68
  • 1
  • 6

1 Answers1

0

Couldn't something like this work?

        await page.goto(url);
        await page.evaluate(() => {
            sessionStorage.setItem(...);
        });
Jazzy
  • 6,029
  • 11
  • 50
  • 74
  • 2
    Hm... we since took a different approach altogether, so I don't really know if it would work. However, I need the data from the sessionStorage at page load, (to authorize the user and not send him to the login screen for example). So, once we have done a page.goto(PageUrl), even if it gets set, we wont have much use for it then. – AnweshCR7 Mar 25 '19 at 08:55
  • @AnweshCR7 then how did u pass the data? – Chanwoo Park Nov 25 '21 at 00:19
  • @Jazzy sessionStorage doesn't exist in node ... – AlxVallejo Dec 21 '22 at 19:45