Class PlaywrightFetcherConfig
java.lang.Object
com.norconex.crawler.core.fetch.BaseFetcherConfig
com.norconex.crawler.web.fetch.impl.playwright.PlaywrightFetcherConfig
Configuration for PlaywrightFetcher.
By default Playwright uses its own downloaded browser binaries
(~/.cache/ms-playwright). To use a system-installed browser instead
(e.g., Chrome, Edge, Firefox already present on the machine or CI runner),
set the channel field (e.g., "chrome",
"msedge", "firefox") — no download is then required.
No external WebDriver binary is ever needed.
- Since:
- 4.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumElement locator strategy forgetWaitForElementSelector(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleangetArgs()Returns an unmodifiable view of the browser launch arguments.The browser engine used for crawling.Maximum age of a per-thread browser instance before it is restarted.intA maximum number of navigations after which each per-thread browser instance is restarted.Optional browser channel that instructs Playwright to use a system-installed browser instead of its own downloaded binaries.@NonNull DurationInterval between checks for idle (unused) browser instances to close.Optional JavaScript code executed immediately after page navigation, before any wait conditions are applied.Optional path to a custom browser executable.Optional JavaScript code executed after all wait conditions have been satisfied.Maximum time to wait for the page load event.Proxy settings used when launching the browser.When configured, takes a screenshot of each fetched page and stores it according to the handler's configuration (document metadata field or local directory).Optional slow-motion delay applied between Playwright operations.Selector expression used to wait for a specific element to appear in the page before returning.Maximum time to wait for the element identified bygetWaitForElementSelector()to appear.The type of reference used when waiting for an element to appear.Optional browser viewport size.inthashCode()booleanWhether to run the browser in headless mode.booleanWhentrue, HTTPS certificate errors are ignored.Sets the browser launch arguments.setBrowser(PlaywrightBrowser browser) The browser engine used for crawling.setBrowserMaxAge(Duration browserMaxAge) Maximum age of a per-thread browser instance before it is restarted.setBrowserMaxNavigations(int browserMaxNavigations) A maximum number of navigations after which each per-thread browser instance is restarted.setChannel(String channel) Optional browser channel that instructs Playwright to use a system-installed browser instead of its own downloaded binaries.setCleanupInterval(@NonNull Duration cleanupInterval) Interval between checks for idle (unused) browser instances to close.setEarlyPageScript(String earlyPageScript) Optional JavaScript code executed immediately after page navigation, before any wait conditions are applied.setExecutablePath(Path executablePath) Optional path to a custom browser executable.setHeadless(boolean headless) Whether to run the browser in headless mode.setIgnoreHttpsErrors(boolean ignoreHttpsErrors) Whentrue, HTTPS certificate errors are ignored.setLatePageScript(String latePageScript) Optional JavaScript code executed after all wait conditions have been satisfied.setPageLoadTimeout(Duration pageLoadTimeout) Maximum time to wait for the page load event.setProxySettings(ProxySettings proxySettings) Proxy settings used when launching the browser.setScreenshotHandler(PlaywrightScreenshotHandler screenshotHandler) When configured, takes a screenshot of each fetched page and stores it according to the handler's configuration (document metadata field or local directory).Optional slow-motion delay applied between Playwright operations.setWaitForElementSelector(String waitForElementSelector) Selector expression used to wait for a specific element to appear in the page before returning.setWaitForElementTimeout(Duration waitForElementTimeout) Maximum time to wait for the element identified bygetWaitForElementSelector()to appear.setWaitForElementType(PlaywrightFetcherConfig.WaitElementType waitForElementType) The type of reference used when waiting for an element to appear.setWindowSize(Dimension windowSize) Optional browser viewport size.toString()Methods inherited from class com.norconex.crawler.core.fetch.BaseFetcherConfig
getReferenceFilters, setReferenceFilters
-
Constructor Details
-
PlaywrightFetcherConfig
public PlaywrightFetcherConfig()
-
-
Method Details
-
getArgs
Returns an unmodifiable view of the browser launch arguments. UsesetArgs(List)to replace the list.- Returns:
- unmodifiable list of launch arguments
-
setArgs
Sets the browser launch arguments.- Parameters:
args- launch arguments- Returns:
- this config
-
getBrowser
The browser engine used for crawling. Default isPlaywrightBrowser.CHROMIUM. -
isHeadless
public boolean isHeadless()Whether to run the browser in headless mode. Default istrue. -
getChannel
Optional browser channel that instructs Playwright to use a system-installed browser instead of its own downloaded binaries. Supported values:"chrome","msedge","firefox". Leave blank (the default) to use Playwright's bundled browser binaries. -
getExecutablePath
Optional path to a custom browser executable. Whennull, Playwright uses the bundled browser binary it downloaded. -
isIgnoreHttpsErrors
public boolean isIgnoreHttpsErrors()Whentrue, HTTPS certificate errors are ignored. Default isfalse. -
getSlowMo
Optional slow-motion delay applied between Playwright operations. Useful for debugging. Default isnull(no delay). -
getPageLoadTimeout
Maximum time to wait for the page load event. Whennull, the Playwright default (30 s) applies. -
getEarlyPageScript
Optional JavaScript code executed immediately after page navigation, before any wait conditions are applied. -
getLatePageScript
Optional JavaScript code executed after all wait conditions have been satisfied. -
getWaitForElementType
The type of reference used when waiting for an element to appear. Used together withgetWaitForElementSelector(). Default isPlaywrightFetcherConfig.WaitElementType.CSSSELECTOR. -
getWaitForElementSelector
Selector expression used to wait for a specific element to appear in the page before returning. The kind of expression is defined bygetWaitForElementType(). Whennull, no element wait is performed. -
getWaitForElementTimeout
Maximum time to wait for the element identified bygetWaitForElementSelector()to appear. Whennull, the Playwright default timeout applies. -
getWindowSize
Optional browser viewport size. Whennull, the Playwright default viewport is used. -
getProxySettings
Proxy settings used when launching the browser. When not set (default), no proxy is configured. -
getBrowserMaxAge
Maximum age of a per-thread browser instance before it is restarted. Browsers can accumulate memory over time; restarting periodically can improve stability. Default isnull(no age-based restart). -
getCleanupInterval
Interval between checks for idle (unused) browser instances to close. Cannot benull. Defaults to 10 seconds. -
getScreenshotHandler
When configured, takes a screenshot of each fetched page and stores it according to the handler's configuration (document metadata field or local directory). -
setBrowser
The browser engine used for crawling. Default isPlaywrightBrowser.CHROMIUM.- Returns:
this.
-
setHeadless
Whether to run the browser in headless mode. Default istrue.- Returns:
this.
-
setChannel
Optional browser channel that instructs Playwright to use a system-installed browser instead of its own downloaded binaries. Supported values:"chrome","msedge","firefox". Leave blank (the default) to use Playwright's bundled browser binaries.- Returns:
this.
-
setExecutablePath
Optional path to a custom browser executable. Whennull, Playwright uses the bundled browser binary it downloaded.- Returns:
this.
-
setIgnoreHttpsErrors
Whentrue, HTTPS certificate errors are ignored. Default isfalse.- Returns:
this.
-
setSlowMo
Optional slow-motion delay applied between Playwright operations. Useful for debugging. Default isnull(no delay).- Returns:
this.
-
setPageLoadTimeout
Maximum time to wait for the page load event. Whennull, the Playwright default (30 s) applies.- Returns:
this.
-
setEarlyPageScript
Optional JavaScript code executed immediately after page navigation, before any wait conditions are applied.- Returns:
this.
-
setLatePageScript
Optional JavaScript code executed after all wait conditions have been satisfied.- Returns:
this.
-
setWaitForElementType
public PlaywrightFetcherConfig setWaitForElementType(PlaywrightFetcherConfig.WaitElementType waitForElementType) The type of reference used when waiting for an element to appear. Used together withgetWaitForElementSelector(). Default isPlaywrightFetcherConfig.WaitElementType.CSSSELECTOR.- Returns:
this.
-
setWaitForElementSelector
Selector expression used to wait for a specific element to appear in the page before returning. The kind of expression is defined bygetWaitForElementType(). Whennull, no element wait is performed.- Returns:
this.
-
setWaitForElementTimeout
Maximum time to wait for the element identified bygetWaitForElementSelector()to appear. Whennull, the Playwright default timeout applies.- Returns:
this.
-
setWindowSize
Optional browser viewport size. Whennull, the Playwright default viewport is used.- Returns:
this.
-
setProxySettings
Proxy settings used when launching the browser. When not set (default), no proxy is configured.- Returns:
this.
-
setBrowserMaxAge
Maximum age of a per-thread browser instance before it is restarted. Browsers can accumulate memory over time; restarting periodically can improve stability. Default isnull(no age-based restart).- Returns:
this.
-
setCleanupInterval
Interval between checks for idle (unused) browser instances to close. Cannot benull. Defaults to 10 seconds.- Returns:
this.
-
setScreenshotHandler
When configured, takes a screenshot of each fetched page and stores it according to the handler's configuration (document metadata field or local directory).- Returns:
this.
-
equals
- Overrides:
equalsin classBaseFetcherConfig
-
canEqual
- Overrides:
canEqualin classBaseFetcherConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseFetcherConfig
-
toString
- Overrides:
toStringin classBaseFetcherConfig
-