0

I am running the following code:

    const browserFetcher = puppeteer.createBrowserFetcher();
    //revision corresponds to Chrome 69.0.3497.92
    const revisionInfo = await browserFetcher.download('576753');
    const browser = await puppeteer.launch({
        executablePath: revisionInfo.executablePath,
        headless: false,
        ignoreHTTPSErrors: true,
        args: [
            '--no-sandbox',
            '--disable-setuid-sandbox'
        ]
    });
    const page = await browser.newPage();
    await page.goto(link, { waitUntil: 'networkidle2' });
    await page.waitForSelector('button.btn-primary', { visible: true });
    const thisLineIsNeverReached = 0;

The problem is that the const thisLineIsNeverReached = 0; line is never reached and the Puppeteer throws an error saying that the 'button.btn-primary' selector timed out.

I checked that the specified element is indeed present on a page: enter image description here

I am using the "puppeteer": "11.0.0" version.

So, why may Puppeteer not see the element?

manymanymore
  • 2,251
  • 3
  • 26
  • 48
  • `checked that the specified element is indeed present on a page` Did you check it in the puppeteer's browser? Is it visible in the viewport without scrolling? – Vaviloff Mar 25 '22 at 04:57
  • @Vaviloff, yes it is visible. – manymanymore Mar 25 '22 at 09:15
  • chrome 69 is a 4-5 years old browser and puppeteer is guaranteed to work only with the bundled chromium version. if you want to use this specific chrome I suggest downgrading to a matching puppeteer. it will be v0.x (so a very old one, before becoming stable) – theDavidBarton Mar 25 '22 at 09:31
  • @theDavidBarton, is there a table of Chromium versions for each Puppeteer version? I would rather bring the Chromium version up, but I do not know which revision to use instead of the `576753`. – manymanymore Mar 25 '22 at 09:41
  • 2
    Is there a specific reason why you can not use the bundled Chromium? – Vaviloff Mar 25 '22 at 10:03
  • @manymanymore for the version matching you can use this file: https://github.com/puppeteer/puppeteer/blob/main/versions.js (above pptr v1.12.2). and Vaviloff has a fair question. I'd suggest first trying to use the bundled Chromium, if your issue still occurs then maybe it won't be the chrome version that is the culprit. but I believe it can be a cause your script fails. – theDavidBarton Mar 25 '22 at 10:08
  • @theDavidBarton, how can I map the version to revision? E.g. what revision does the `'100.0.4889.0'` version have? – manymanymore Mar 25 '22 at 12:13
  • I don't remember the primary source for the revision numbers (they are generated from build hashes if I remember well. _update:_ see it [here](https://stackoverflow.com/a/56366776/12412595)), but you can use this git commit query on the pptr repo to see the revision for bundled chrome versions from the past: [roll+chromium+to](https://github.com/puppeteer/puppeteer/search?q=roll+chromium+to&type=commits). based on this: 100.0.4889.0 => `970485` – theDavidBarton Mar 25 '22 at 15:53

1 Answers1

0

Changing the:

const revisionInfo = await browserFetcher.download('576753');
const browser = await puppeteer.launch({
    executablePath: revisionInfo.executablePath,
    headless: false,
    ignoreHTTPSErrors: true,
    args: [
        '--no-sandbox',
        '--disable-setuid-sandbox'
    ]
});

to the:

const browser = await puppeteer.launch({
    headless: false,
    ignoreHTTPSErrors: true,
    args: [
        '--no-sandbox',
        '--disable-setuid-sandbox'
    ]
});

and then changing all the references throughout the project from the puppeteer-core to the puppeteer solved the issue.

Also, this approach allows not to keep a constant track of the latest revision. Puppeteer will download and use a correct revision automatically.

manymanymore
  • 2,251
  • 3
  • 26
  • 48