feat(chromium): add waitForSelector option to Chromium conversions (#1446)

* Add `waitForSelector` option to Chromium conversions

Closes #960

As an alternative to waiting on an expression, this allows users to wait
for a specific node matching a selector to become visible in the HTML /
at the remote URL before converting to PDF.

* Fix style / prettify
This commit is contained in:
Daniel Moran
2026-01-17 05:57:10 -08:00
committed by GitHub
parent 92de0cf6fe
commit 3220ca4140
8 changed files with 122 additions and 2 deletions

View File

@@ -33,6 +33,10 @@ var (
// returns an exception or undefined.
ErrInvalidEvaluationExpression = errors.New("invalid evaluation expression")
// ErrInvalidSelectorQuery happens if a selector query returns an exception
// or undefined.
ErrInvalidSelectorQuery = errors.New("invalid selector query")
// ErrRpccMessageTooLarge happens when the messages received by
// ChromeDevTools are larger than 100 MB.
ErrRpccMessageTooLarge = errors.New("rpcc message too large")
@@ -142,6 +146,10 @@ type Options struct {
// converting an HTML document until it returns true
WaitForExpression string
// WaitForSelector is the element query to wait until visible before
// converting an HTML document.
WaitForSelector string
// Cookies are the cookies to put in the Chromium cookies' jar.
Cookies []Cookie
@@ -173,6 +181,7 @@ func DefaultOptions() Options {
WaitDelay: 0,
WaitWindowStatus: "",
WaitForExpression: "",
WaitForSelector: "",
Cookies: nil,
UserAgent: "",
ExtraHttpHeaders: nil,