Skip to content

Support Playwright locators #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexkreidler opened this issue Apr 24, 2025 · 1 comment
Open

Support Playwright locators #564

alexkreidler opened this issue Apr 24, 2025 · 1 comment
Labels
CDP Chrome Debug Protocol playwright

Comments

@alexkreidler
Copy link

My code:

        console.log(`  Navigating to ${url}...`);
        await page.goto(url, { waitUntil: 'networkidle', timeout: 5000 }); // Increased timeout
        console.log(`  Navigation successful.`);

        console.log(`  Extracting body text...`);
        const text = await page.evaluate(() => {
          // Use DOM API to extract text
          const body = document.querySelector('body');
          return body ? 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...
@krichprollsch
Copy link
Member

Hello @alexkreidler,

We have multiples issues currently with Playwright, but we plan to focus on it the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDP Chrome Debug Protocol playwright
Projects
None yet
Development

No branches or pull requests

2 participants