Skip to content

postPageCreateHooks does not fire if useFingerprints is set to true #82

@ejames17

Description

@ejames17

Steps to reproduce:

  1. Run example code taken from doc
import { BrowserPool, PlaywrightPlugin } from "browser-pool";
import playwright from "playwright";


const browserPool = new BrowserPool({
    browserPlugins: [new PlaywrightPlugin(playwright.chromium)],
    useFingerprints: false,
    preLaunchHooks: [(pageId, launchContext) => {
        // do something before a browser gets launched
        launchContext.launchOptions.headless = false;
    }],
    postLaunchHooks: [(pageId, browserController) => {
        // manipulate the browser right after launch
        //console.dir(browserController.browser.contexts());
    }],
    prePageCreateHooks: [(pageId, browserController) => {
        if (pageId === 'my-page') {
            // make changes right before a specific page is created
        }
    }],
    postPageCreateHooks: [async (page, browserController) => {
        // update some or all new pages
        console.log('postPageCreateHooks fired');
        await page.evaluate(() => {
            // now all pages will have 'foo'
            window.foo = 'bar'
        })
    }],
    prePageCloseHooks: [async (page, browserController) => {
        // collect information just before a page closes
       // await page.screenshot();
    }],
    postPageCloseHooks: [(pageId, browserController) => {
        // clean up or log after a job is done
        console.log('Page closed: ', pageId)
    }]

});
await browserPool.newPageInNewBrowser();
await browserPool.newPage();
  1. set argument useFingerprints: true,
  2. expected: text to be printed to console 'postPageCreateHooks fired' however it does not get triggered.

If I switch useFingerprint to false everything fires as expected

node -v: 17.7.0
OS: windows server 2022 standard 21H2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions