/screenshot api: add support for `waitForSelector`

This issue has been tracked since 2022-08-26.

Is your feature request related to a problem? Please describe.
When specifying a selector for the screenshot api that's not initially available on page render, puppeteers waitForSelector isn't used and the api returns a 400 Bad Request with a NPE

Describe the solution you'd like
When specifying a selector i want to take a screenshot as soon as the element is available

Describe alternatives you've considered
You can use networkidle0 etc in the goto options but awaiting a specific selector gives you more control (if you take a snapshot of a website you have control over)

Additional context

andyMrtnzP wrote this answer on 2022-08-29

You can wait for a selector adding a waitFor entry in the JSON payload, this way:

  "url": "https://example.com/",
  "waitFor": "h1"

You can also wait for a timeout

  "url": "https://example.com/",
  "waitFor": 5000

Or a function

  "url": "https://example.com/",
  "waitFor": "() => document.querySelector(`h1`).innerText = `Hello World!`"

Though we now realize that our docs for that API don't really make the waitFor clear, thanks for bringing that to our attention!

More Details About Repo
Owner Name browserless
Repo Name chrome
Full Name browserless/chrome
Language TypeScript
Created Date 2017-11-17
Updated Date 2023-03-22
Star Count 5309
Watcher Count 47
Fork Count 516
Issue Count 29


Issue Title Created Date Updated Date