apify/fingerprint-suite

page.setUserAgent is not a function when using Playwright

Closed this issue · 1 comments

Describe the bug
Error thrown when using newInjectedPage with playwright.

To Reproduce

import { chromium } from 'playwright';

(async () => {
    const browser = await chromium.launch({ headless: false });
    const context = await newInjectedContext(
        browser,
        {
            fingerprintOptions: {
                devices: ['mobile'],
                operatingSystems: ['ios'],
            },
        },
    );

    const page = awai newInjectedPage(browser, {
      fingerprintOptions: {
        devices:          ['mobile'],
        operatingSystems: ['ios']
      }
    });

})();

Expected behavior
Execute as normally, injecting a fingerprint into the page.

System information:

  • OS: MacOS
  • Node.js version: v18.15.0

Additional context
newInjectedContext works fine.

Please note that the newInjectedPage function is for use with Puppeteer only. This is reflected in the function's type annotation - it shouldn't be possible to pass the Playwright browser instance to the method. With Playwright, use the newInjectedContext function instead.

I'll close this issue now as it's a wontfix, but I'll look into improving the documentation (and parameter validation), so the divide is more clear. Cheers!