Closed konsalex closed 1 year ago
The page
puppetter object may be able to do what you need (e.g set localStorage via page.evaluate
). Haven't dug into it but the isPageLoaded parameter is presumably where you'd drop this logic.
isPageLoaded
might potentially do that. However, it will be called after each navigation (triggered by action
and back
). We can add an init(page)
or setup(page)
callback that is called once right after the initial page load.
So with a simple check, if we are logged-in or not, isPageLoaded
could currently do the job? That sounds good to start testing it out!
^ yep, I wanted to very quickly check one thing and had luck with the following, probably not very good but worked for what I wanted
async function isPageLoaded(page) {
await page.evaluate(async () => {
const auth = localStorage.getItem('token');
if (!auth) {
const token = getTokenLogicHere();
localStorage.setItem('token', token);
await page.refresh();
}
});
return await page.evaluate(() => {
return !!document.querySelector(loggedInElement)
})
}
Hey there! Great tool, would love to give this a try, and was curious what would be the best approach to invoke a login process.
Found here the IScenario, and I'm curious if the only strategy here is the Cookie setup.