Skip to content
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

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

Open
ejames17 opened this issue Jul 26, 2022 · 0 comments
Open

Comments

@ejames17
Copy link

ejames17 commented Jul 26, 2022

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

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

No branches or pull requests

1 participant