Which package is this bug report for? If unsure which one to select, leave blank
@crawlee/browser (BrowserCrawler)
Issue description
Injection of localStorage produces error:
DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
Investigation is pointing to https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
PlaywrightCrawler is opening incognito contexts for both Chrome and Firefox. Using the option optionaluseIncognitoPages is not helping.
Code sample
const crawler = new PlaywrightCrawler({
preNavigationHooks: [
async (crawlingContext, gotoOptions) => {
const {page} = crawlingContext;
await page.context().addCookies(cookies.map(cookie => ({...cookie, sameSite: 'None'})));
{
const data = storage;
const code = items =>
Object
.entries(items)
.forEach(([key, value]) => localStorage[key] = value);
await page.evaluate(code, data).catch(error => console.warn(error.message));
}
},
],
postNavigationHooks: [
async (crawlingContext, gotoOptions) => {
await crawlingContext.closeCookieModals();
}
],
headless: false,
// proxyConfiguration: new ProxyConfiguration({ proxyUrls: ['...'] }),
requestHandler: router,
// Comment this option to scrape the full website.
maxRequestsPerCrawl: 20,
requestHandlerTimeoutSecs: 5 * 60,
useSessionPool: true,
persistCookiesPerSession: true,
launchContext: {
launcher: firefox,
useChrome: true,
useIncognitoPages: false
},
Package version
latest
Node.js version
latest
Operating system
No response
Apify platform
I have tested this on the next release
No response
Other context
No response
Which package is this bug report for? If unsure which one to select, leave blank
@crawlee/browser (BrowserCrawler)
Issue description
Injection of
localStorageproduces error:DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.Investigation is pointing to https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
PlaywrightCrawleris opening incognito contexts for both Chrome and Firefox. Using the optionoptionaluseIncognitoPagesis not helping.Code sample
Package version
latest
Node.js version
latest
Operating system
No response
Apify platform
I have tested this on the
nextreleaseNo response
Other context
No response