You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log(` Navigating to ${url}...`);awaitpage.goto(url,{waitUntil: 'networkidle',timeout: 5000});// Increased timeoutconsole.log(` Navigation successful.`);console.log(` Extracting body text...`);consttext=awaitpage.evaluate(()=>{// Use DOM API to extract textconstbody=document.querySelector('body');returnbody ? body.innerText : '';});// const text = await page.locator('body').innerText();console.log(` Text extracted (${text.length} characters).`);console.log(` Saving text to ${textPath}...`);fs.writeFileSync(textPath,text);console.log(` Text file saved.`);
Do you support Playwright locators? When I tried using const text = await page.locator('body').innerText(); I got:
Error processing https://www.forbes.com/lists/largest-private-companies: locator.innerText: Target page, context or browser has been closed
Call log:
- waiting for locator('body')
at <anonymous> (/Users/al/c2/m2/test-lightpanda/screenshotter.ts:170:49)
Closing page for https://www.forbes.com/lists/largest-private-companies...
Closing context for https://www.forbes.com/lists/largest-private-companies...
The text was updated successfully, but these errors were encountered:
My code:
Do you support Playwright locators? When I tried using
const text = await page.locator('body').innerText();
I got:The text was updated successfully, but these errors were encountered: