Class CdpDriver
- All Implemented Interfaces:
CoreDriver,Driver,io.karatelabs.js.ObjectLike,io.karatelabs.js.SimpleObject
-
Field Summary
Fields inherited from interface io.karatelabs.js.SimpleObject
TO_STRING -
Method Summary
Modifier and TypeMethodDescriptionCreate a finder for elements above the reference element.voidactivate()Activate the browser window (bring to front).voidaddBinding(String name) Expose a global functionwindow.<name>(payload)in every execution context.voidaddCdpEventListener(CdpEventListener listener) Add an external event listener that receives all CDP events.voidaddInitScript(String name, String source, String... deps) Register a named JavaScript module to run in every new document and inject it into the document that is already open.Install a JavaScript source that is evaluated in every new document — the top frame and same-process child frames — before the page's own scripts run, and re-applied on each navigation.Get an attribute of an element.voidback()Navigate back in history.Create a finder for elements below the reference element.Clear an input element.voidClear all cookies.Click an element.voidclose()Close the current tab/page.static voidcloseAll()Close all active drivers.static CdpDriverConnect to an existing browser via WebSocket URL.static CdpDriverconnect(String webSocketUrl, CdpDriverOptions options) Connect to an existing browser with options.static CdpDriverconnectNewContext(String browserWebSocketUrl, CdpDriverOptions options) Connect to an existing browser and create a driver that owns a fresh incognito browser context, with its own page inside it.Get a cookie by name.voidSet a cookie.voiddeleteCookie(String name) Delete a cookie by name.describeNode(int backendNodeId) Describe a node by backend node id (DOM.describeNode) → the node descriptor map ({nodeName, attributes:[name,val,…], …}), ornullon error.voiddialog(boolean accept) Accept or dismiss the current dialog.voidAccept or dismiss the current dialog with optional prompt input.Drain the queue of page targets (tabs) opened since the last call.booleanCheck if an element is enabled.booleanCheck if an element exists.byte[]Best-effort failure-path screenshot, bounded byFAILURE_SCREENSHOT_TIMEOUTso a stalled renderer can't turn a swallowed diagnostic into a full-timeout hang.Focus an element.voidforward()Navigate forward in history.voidMake the browser window fullscreen.Get the CDP-specific options.Get all cookies.Get the current frame, or null if in main frame.Get the current dialog if one is open.Get the current dialog message.Get window dimensions and position.getFrameOwnerBackendNodeId(String frameId) ThebackendNodeIdof the<iframe>/<frame>element that owns the given frame (DOM.getFrameOwner).Get driver options.getPages()Get list of all page targets (tabs).Get info for all page targets (tabs) — targetId, url, title, active flag.getTitle()Get page title.getUrl()Get current URL.Highlight an element.Get the outer HTML of an element.Input text into an element using CDP keypresses.voidintercept(InterceptHandler handler) Enable request interception for all requests.voidintercept(List<String> patterns, InterceptHandler handler) Enable request interception with a handler.booleanisReady()Whether the driver is ready to accept script/element calls right now — i.e. the page's execution context is live (not mid-navigation / mid-tab-switch).booleanBounded liveness probe forreset.invalid reference
PooledDriverProviderbooleanCheck if driver is terminated.keys()Get a Keys object for keyboard input.Create a finder for elements to the left of the reference element.Find an element by locator.Find all elements matching a locator.voidmaximize()Maximize the browser window.voidminimize()Minimize the browser window.mouse()Get a Mouse object at position (0, 0).Get a Mouse object at specified coordinates.Get a Mouse object positioned at an element's center.Create a finder for elements near the reference element.Resolve a locator to the CDPRemoteObjectid (objectId) of its DOM node, ornullif it does not resolve.voidonDialog(DialogHandler handler) Register a handler for JavaScript dialogs (alert, confirm, prompt, beforeunload).Find an element that may not exist (optional).byte[]pdf()Generate a PDF of the current page with default options.byte[]Generate a PDF of the current page.Get the position of an element (absolute).Get the position of an element.Get a property of an element.voidquit()Close driver and browser.voidrefresh()Refresh the current page.voidreload()Reload the page ignoring cache.voidremoveBinding(String name) Remove a binding previously added withaddBinding(String).voidremoveCdpEventListener(CdpEventListener listener) Remove an external event listener.voidremoveInitScript(String name) Unregister a module added withaddInitScript(String, String, String...)so it no longer installs on future navigations.voidremoveScriptToEvaluateOnNewDocument(String identifier) Uninstall a script previously added withaddScriptToEvaluateOnNewDocument(String).Create a finder for elements to the right of the reference element.byte[]Take screenshot and return PNG bytes.byte[]screenshot(boolean embed) Take screenshot, optionally embed in report.byte[]screenshot(String locator, boolean embed) Take a screenshot clipped to the bounding rect of the element matched by the locator.Execute JavaScript and return result.Execute a script on an element.Execute a script on all matching elements.Scroll an element into view.Select an option from a dropdown by index.Select an option from a dropdown by text or value.voidsetDimensions(Map<String, Object> dimensions) Set window dimensions and/or position.voidNavigate to URL and wait for page load.static CdpDriverstart()Launch a new browser with default options.static CdpDriverstart(CdpDriverOptions options) Launch a new browser and create driver.static CdpDriverLaunch a headless browser.voidStop request interception.voidswitchFrame(int index) Switch to an iframe by index in the frame tree.voidswitchFrame(String locator) Switch to an iframe by locator (CSS, XPath, or wildcard).voidswitchPage(int index) Switch to a page by index.voidswitchPage(String titleOrUrl) Switch to a page by title or URL substring.voidswitchPageById(String targetId) Switch to a page by its backend target ID (unambiguous — avoids URL/title collisions thatswitchPage(String)is vulnerable to).Get the text content of an element.Get the value of an input element.Set the value of an input element.Wait for an element to exist.Wait for an element to exist with custom timeout.waitForAny(String[] locators) Wait for any of the locators to match.waitForAny(String[] locators, Duration timeout) Wait for any of the locators to match with custom timeout.waitForAny(String locator1, String locator2) Wait for any of the locators to match.waitForEnabled(String locator) Wait for an element to be enabled.waitForEnabled(String locator, Duration timeout) Wait for an element to be enabled with custom timeout.voidwaitForPageLoad(PageLoadStrategy strategy) Wait for page to load based on strategy.voidwaitForPageLoad(PageLoadStrategy strategy, Duration timeout) Wait for page to load with custom timeout.waitForResultCount(String locator, int count) Wait for a specific number of elements to match.waitForResultCount(String locator, int count, Duration timeout) Wait for a specific number of elements to match with custom timeout.waitForText(String locator, String expected) Wait for an element to contain specific text.waitForText(String locator, String expected, Duration timeout) Wait for an element to contain specific text with custom timeout.waitForUrl(String expected) Wait for URL to contain expected string.waitForUrl(String expected, Duration timeout) Wait for URL to contain expected string with custom timeout.booleanWait until a JavaScript expression evaluates to truthy.Wait until a JavaScript expression on an element evaluates to truthy.Wait until a JavaScript expression on an element evaluates to truthy.booleanWait until a JavaScript expression evaluates to truthy with custom timeout.Wait until a supplier returns a truthy value.Wait until a supplier returns a truthy value with custom timeout.voidBlock until the driver is ready to accept calls (execution context live), or the configured timeout elapses.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.karatelabs.driver.Driver
delay, eval, eval, frame, highlight, highlightAll, highlightAll, input, input, input, jsGet, locateAll, navigate, putMember, screenshot, script, scriptAll, setCookies, submit, tab, timeout, timeout, waitForResultCount, waitIfSubmitRequested, windowMethods inherited from interface io.karatelabs.js.ObjectLike
getMember, getPrototype, isExtensible, isFrozen, isOwnProperty, isSealed, putMember, removeMember, setExtensible, setFrozen, setSealedMethods inherited from interface io.karatelabs.js.SimpleObject
getMember, jsKeys, jsToString, removeMember, toMap
-
Method Details
-
addCdpEventListener
Add an external event listener that receives all CDP events. Used for traffic recording, debugging, etc.- Parameters:
listener- The listener to add
-
removeCdpEventListener
Remove an external event listener.- Parameters:
listener- The listener to remove
-
addScriptToEvaluateOnNewDocument
Install a JavaScript source that is evaluated in every new document — the top frame and same-process child frames — before the page's own scripts run, and re-applied on each navigation. Returns an identifier thatremoveScriptToEvaluateOnNewDocument(String)takes to uninstall it.- Parameters:
source- the JavaScript source to install- Returns:
- the install identifier, or
nullif none was returned
-
removeScriptToEvaluateOnNewDocument
Uninstall a script previously added withaddScriptToEvaluateOnNewDocument(String).- Parameters:
identifier- the install identifier returned at add time
-
addBinding
Expose a global functionwindow.<name>(payload)in every execution context. Each call from page script surfaces as aRuntime.bindingCalledCDP event delivered to listeners registered viaaddCdpEventListener(CdpEventListener)— a one-way channel for page code to push string payloads back to the driver.- Parameters:
name- the global function name to expose
-
removeBinding
Remove a binding previously added withaddBinding(String).- Parameters:
name- the global function name to remove
-
addInitScript
Register a named JavaScript module to run in every new document and inject it into the document that is already open. Modules are installed after the built-in page runtime and after any modules named indeps, so a module can rely on the sharedwindowutilities the runtime and its dependencies provide without managing injection order itself. The built-in runtime is installed (once) on the first registration; with no modules registered it stays injected lazily on demand, so the default page footprint is unchanged.Idempotent by
name— a second call for an already-registered name is a no-op (so a module may carry its own re-entry guard and be safely re-evaluated on each navigation). Pair withremoveInitScript(String).- Parameters:
name- a stable identifier for the modulesource- the JavaScript sourcedeps- names of already-registered modules that must run before this one- Throws:
DriverException- if a declared dependency has not been registered
-
removeInitScript
Unregister a module added withaddInitScript(String, String, String...)so it no longer installs on future navigations. The copy already running in the current document is left in place. No-op ifnameis not registered.- Parameters:
name- the module identifier passed toaddInitScript
-
getFrameOwnerBackendNodeId
ThebackendNodeIdof the<iframe>/<frame>element that owns the given frame (DOM.getFrameOwner). The owner element always lives in the parent document — only its content may be cross-origin — so this resolves even for an out-of-process (OOPIF) child frame, which is what lets the caller name a within-parent selector for a frame it cannot reach from inside. Enables the DOM domain lazily (idempotent). Returnsnullfor the top-level frame (no owner) or on any error.- Parameters:
frameId- the CDP frame id (e.g. correlated fromRuntime.executionContextCreated)- Returns:
- the owner element's backend node id, or
null
-
describeNode
Describe a node by backend node id (DOM.describeNode) → the node descriptor map ({nodeName, attributes:[name,val,…], …}), ornullon error. Pairs withgetFrameOwnerBackendNodeId(String)to derive an owner-<iframe>selector. -
start
Launch a new browser and create driver. -
start
Launch a new browser with default options. -
startHeadless
Launch a headless browser. -
connect
Connect to an existing browser via WebSocket URL. -
connect
Connect to an existing browser with options. -
connectNewContext
Connect to an existing browser and create a driver that owns a fresh incognito browser context, with its own page inside it. This is the isolation primitive for running drivers in parallel against ONE browser.Prefer this over
connect(String, CdpDriverOptions)whenever several drivers share a browser. Tabs opened in the DEFAULT browser context share one cookie jar and one storage partition, so they are not isolated in any meaningful sense:Network.clearBrowserCookies— which the pooled reset calls on every acquire — is browser-context-wide, so one scenario resetting silently wipes the cookies of every other scenario running concurrently in that context. Per-tab clearing cannot fix that; there is only one jar to clear. A per-driver context gives each driver its own jar, so the reset only ever affects its own scenario.The returned driver owns the context and disposes it (closing its tab with it) on
quit().- Parameters:
browserWebSocketUrl- a BROWSER-level endpoint (ws://host:port/devtools/browser/...), not a page endpoint — see /json/version
-
closeAll
public static void closeAll()Close all active drivers. -
setUrl
Description copied from interface:DriverNavigate to URL and wait for page load. -
waitForPageLoad
Wait for page to load based on strategy.- Specified by:
waitForPageLoadin interfaceDriver
-
waitForPageLoad
Wait for page to load with custom timeout.- Specified by:
waitForPageLoadin interfaceDriver
-
getUrl
Get current URL. -
getTitle
Get page title. -
script
Execute JavaScript and return result. -
screenshot
public byte[] screenshot()Take screenshot and return PNG bytes.- Specified by:
screenshotin interfaceCoreDriver- Specified by:
screenshotin interfaceDriver- Returns:
- PNG image bytes
-
screenshot
public byte[] screenshot(boolean embed) Take screenshot, optionally embed in report.- Specified by:
screenshotin interfaceDriver
-
failureScreenshot
public byte[] failureScreenshot()Best-effort failure-path screenshot, bounded byFAILURE_SCREENSHOT_TIMEOUTso a stalled renderer can't turn a swallowed diagnostic into a full-timeout hang.- Specified by:
failureScreenshotin interfaceDriver
-
screenshot
Take a screenshot clipped to the bounding rect of the element matched by the locator. Uses CDP'sPage.captureScreenshotwith aclipparam — matches v1 behavior.- Specified by:
screenshotin interfaceDriver
-
onDialog
Register a handler for JavaScript dialogs (alert, confirm, prompt, beforeunload). When a dialog opens, the handler is called with a Dialog object. The handler should call dialog.accept() or dialog.dismiss() to resolve the dialog. -
getDialogText
Get the current dialog message.- Specified by:
getDialogTextin interfaceDriver- Returns:
- the dialog message, or null if no dialog is open
-
getDialog
Get the current dialog if one is open. This is useful for detecting dialogs that appear after actions (e.g., click). The dialog remains available until handled via dialog() or the Dialog methods. -
dialog
public void dialog(boolean accept) Accept or dismiss the current dialog. This is used when no DialogHandler is registered. -
dialog
Accept or dismiss the current dialog with optional prompt input. This is used when no DialogHandler is registered.- Specified by:
dialogin interfaceCoreDriver- Specified by:
dialogin interfaceDriver- Parameters:
accept- true to accept (OK), false to dismiss (Cancel)input- the text to enter for prompt dialogs (ignored if accept is false)
-
switchFrame
public void switchFrame(int index) Switch to an iframe by index in the frame tree.- Specified by:
switchFramein interfaceDriver- Parameters:
index- the zero-based index of the frame
-
switchFrame
Switch to an iframe by locator (CSS, XPath, or wildcard). Pass null to switch back to the main frame.- Specified by:
switchFramein interfaceDriver- Parameters:
locator- the locator for the iframe element, or null to return to main frame
-
getCurrentFrame
Get the current frame, or null if in main frame.- Specified by:
getCurrentFramein interfaceDriver- Returns:
- the current frame info, or null
-
quit
public void quit()Close driver and browser.- Specified by:
quitin interfaceCoreDriver- Specified by:
quitin interfaceDriver
-
close
public void close()Close the current tab/page. After closing, automatically switches to another open tab if available. If this is the last tab, creates a blank page first to keep the browser alive. DESIGN NOTE: We must switch to another tab BEFORE closing the current one. When connected via page-specific WebSocket URL (e.g., /devtools/page/xxx), closing that page also closes the WebSocket connection. By switching first, we establish a new session on a different target, then safely close the old one. -
isTerminated
public boolean isTerminated()Description copied from interface:DriverCheck if driver is terminated.- Specified by:
isTerminatedin interfaceCoreDriver- Specified by:
isTerminatedin interfaceDriver
-
isReady
public boolean isReady()Description copied from interface:DriverWhether the driver is ready to accept script/element calls right now — i.e. the page's execution context is live (not mid-navigation / mid-tab-switch). Cheap and non-blocking. Backends without an explicit readiness signal report true. -
waitUntilReady
public void waitUntilReady()Description copied from interface:DriverBlock until the driver is ready to accept calls (execution context live), or the configured timeout elapses. Idempotent and safe to call when already ready (returns immediately). Intended for clients, pools, and providers that want an explicit barrier before driving — e.g.PooledDriverProviderafter acquiring/reusing a driver, so a scenario's first call never races a not-yet-ready context. The default is a no-op for backends that establish readiness synchronously.- Specified by:
waitUntilReadyin interfaceDriver
-
isResponsive
public boolean isResponsive()Bounded liveness probe forreset.invalid reference
PooledDriverProviderEvaluates
new Promise(r => setTimeout(() => r(true), 0))withawaitPromiseand a 3-second CDP timeout (vs the default 30s). Returns false on any error, timeout, or closed socket — the caller treats false as "discard this driver, create a fresh one for the next scenario."Why this exists (context for future maintainers): observed in CI as deterministic "CDP timeout for: Page.navigate" failures in cookie.feature and keys.feature (same scenarios every run, alternating cookie pattern — classic "poisoned pool driver" signature). Every failing run was preceded by tab-switch.feature, which makes 5 activateTarget / Target.attachToTarget calls back-to-back. Each attach creates a new session on the driver's websocket and old sessions are never detached — the accumulated session state appears to leave Chrome unable to respond to Page.navigate on that specific driver, while the other pool driver stays healthy. Without this probe the broken driver kept getting handed back out and every other cookie scenario timed out at 30s.
Why a timer, not
evaluate("1"): a CPU-starved renderer under a slow CI container can evaluate synchronous JS instantly yet never fire asetTimeout— the "timer never fires" degradation that starves page-drivenwaitUntilconditions and lets a poisoned tab go back into the pool. Gating on asetTimeout(…, 0)that must resolve through the macrotask queue makes the probe fail for a stalled timer queue as well as a wedged channel (a microtask likePromise.resolve()would not — it can settle while timers are starved).awaitPromiseblocks the CDP call until the timer resolves, so a stuck renderer trips the bounded timeout. We probe Runtime.evaluate rather than Page.navigate because it's cheap and local (no network).- Specified by:
isResponsivein interfaceDriver
-
getCdpClient
-
getOptions
Description copied from interface:DriverGet driver options.- Specified by:
getOptionsin interfaceCoreDriver- Specified by:
getOptionsin interfaceDriver
-
getCdpOptions
Get the CDP-specific options. -
click
Click an element. -
focus
Focus an element. -
clear
Clear an input element. -
input
Input text into an element using CDP keypresses. For time/date inputs that don't respond to CDP keystrokes, uses JS value assignment. -
value
Set the value of an input element. -
select
Select an option from a dropdown by text or value. -
select
Select an option from a dropdown by index. -
scroll
Scroll an element into view. -
highlight
Highlight an element. -
text
Get the text content of an element. -
html
Get the outer HTML of an element. -
value
Get the value of an input element. -
attribute
Get an attribute of an element. -
property
Get a property of an element. -
enabled
Check if an element is enabled. -
exists
Check if an element exists. -
position
Get the position of an element (absolute). -
position
Get the position of an element. -
locate
Find an element by locator. -
locateAll
Find all elements matching a locator. -
optional
Find an element that may not exist (optional). -
script
Execute a script on an element. The element is available as '_' in the expression. Expression can be a String ("_.value") or JsFunction (_ => _.value). -
objectId
Resolve a locator to the CDPRemoteObjectid (objectId) of its DOM node, ornullif it does not resolve.script(String, Object)returns a node BY VALUE (no remote handle); a CDP domain method that addresses a node by reference — e.g.DOM.setFileInputFilesfor a file upload — needs the liveobjectId. This is the one locator→CDP-node primitive those operations require. It runs in the resolved frame context (same asscript(String)) and, unlike the click/input path, does NOT require the element to be visible — a file<input>is routinelydisplay:none. Does not poll/retry for existence; the caller decides how to handle anull. -
scriptAll
Execute a script on all matching elements. Each element is available as '_' in the expression. Expression can be a String or JsFunction. -
waitFor
Wait for an element to exist. -
waitFor
Wait for an element to exist with custom timeout. -
waitForAny
Wait for any of the locators to match.- Specified by:
waitForAnyin interfaceDriver
-
waitForAny
Wait for any of the locators to match.- Specified by:
waitForAnyin interfaceDriver
-
waitForAny
Wait for any of the locators to match with custom timeout.- Specified by:
waitForAnyin interfaceDriver
-
waitForText
Wait for an element to contain specific text.- Specified by:
waitForTextin interfaceDriver
-
waitForText
Wait for an element to contain specific text with custom timeout.- Specified by:
waitForTextin interfaceDriver
-
waitForEnabled
Wait for an element to be enabled.- Specified by:
waitForEnabledin interfaceDriver
-
waitForEnabled
Wait for an element to be enabled with custom timeout.- Specified by:
waitForEnabledin interfaceDriver
-
waitForUrl
Wait for URL to contain expected string.- Specified by:
waitForUrlin interfaceDriver
-
waitForUrl
Wait for URL to contain expected string with custom timeout.- Specified by:
waitForUrlin interfaceDriver
-
waitUntil
Wait until a JavaScript expression on an element evaluates to truthy. The element is available as '_' in the expression. -
waitUntil
Wait until a JavaScript expression on an element evaluates to truthy. -
waitUntil
Wait until a JavaScript expression evaluates to truthy. -
waitUntil
Wait until a JavaScript expression evaluates to truthy with custom timeout. -
waitUntil
Wait until a supplier returns a truthy value. -
waitUntil
Wait until a supplier returns a truthy value with custom timeout. -
waitForResultCount
Wait for a specific number of elements to match.- Specified by:
waitForResultCountin interfaceDriver
-
waitForResultCount
Wait for a specific number of elements to match with custom timeout.- Specified by:
waitForResultCountin interfaceDriver
-
cookie
Get a cookie by name.- Specified by:
cookiein interfaceCoreDriver- Specified by:
cookiein interfaceDriver- Parameters:
name- the cookie name- Returns:
- the cookie as a Map, or null if not found
-
cookie
Set a cookie.- Specified by:
cookiein interfaceCoreDriver- Specified by:
cookiein interfaceDriver- Parameters:
cookie- the cookie as a Map with keys: name, value, domain, path, secure, httpOnly, sameSite, expires
-
deleteCookie
Delete a cookie by name.- Specified by:
deleteCookiein interfaceDriver- Parameters:
name- the cookie name
-
clearCookies
public void clearCookies()Clear all cookies.- Specified by:
clearCookiesin interfaceDriver
-
getCookies
Get all cookies.- Specified by:
getCookiesin interfaceDriver- Returns:
- list of cookies as Maps
-
maximize
public void maximize()Maximize the browser window. -
minimize
public void minimize()Minimize the browser window. -
fullscreen
public void fullscreen()Make the browser window fullscreen.- Specified by:
fullscreenin interfaceDriver
-
getDimensions
Get window dimensions and position.- Specified by:
getDimensionsin interfaceDriver- Returns:
- Map with keys: x, y, width, height, windowState
-
setDimensions
Set window dimensions and/or position.- Specified by:
setDimensionsin interfaceDriver- Parameters:
dimensions- Map with optional keys: x, y, width, height, windowState
-
pdf
Generate a PDF of the current page.- Specified by:
pdfin interfaceCoreDriver- Specified by:
pdfin interfaceDriver- Parameters:
options- Map with optional keys: scale, displayHeaderFooter, headerTemplate, footerTemplate, printBackground, landscape, pageRanges, paperWidth, paperHeight, marginTop, marginBottom, marginLeft, marginRight- Returns:
- PDF bytes
-
pdf
public byte[] pdf()Generate a PDF of the current page with default options. -
refresh
public void refresh()Refresh the current page. -
reload
public void reload()Reload the page ignoring cache. -
back
public void back()Navigate back in history. -
forward
public void forward()Navigate forward in history. -
activate
public void activate()Activate the browser window (bring to front). -
mouse
Get a Mouse object at position (0, 0).- Specified by:
mousein interfaceCoreDriver- Specified by:
mousein interfaceDriver- Returns:
- a new Mouse object
-
mouse
Get a Mouse object positioned at an element's center. -
mouse
Get a Mouse object at specified coordinates. -
keys
Get a Keys object for keyboard input. Returns the same instance to maintain modifier state (e.g., holding Shift across multiple calls).- Specified by:
keysin interfaceCoreDriver- Specified by:
keysin interfaceDriver- Returns:
- the Keys object for this driver
-
getPages
Get list of all page targets (tabs). Uses browserMethod() because Target.getTargets is a browser-level command. -
getTargetInfos
Get info for all page targets (tabs) — targetId, url, title, active flag. Richer counterpart togetPages()for callers that need to present tab info to a user (or LLM) before switching.- Returns:
- list of maps with keys: targetId, url, title, active
-
switchPage
Switch to a page by title or URL substring. Includes verification that the switch was successful.- Specified by:
switchPagein interfaceDriver- Parameters:
titleOrUrl- the title or URL substring to match
-
switchPageById
Switch to a page by its backend target ID (unambiguous — avoids URL/title collisions thatswitchPage(String)is vulnerable to).- Specified by:
switchPageByIdin interfaceDriver
-
drainOpenedTargets
Drain the queue of page targets (tabs) opened since the last call. Event-driven — no CDP round-trip. SeeDriver.drainOpenedTargets().- Specified by:
drainOpenedTargetsin interfaceDriver
-
switchPage
public void switchPage(int index) Switch to a page by index.- Specified by:
switchPagein interfaceDriver- Parameters:
index- the zero-based index
-
rightOf
Create a finder for elements to the right of the reference element. -
leftOf
Create a finder for elements to the left of the reference element. -
above
Create a finder for elements above the reference element. -
below
Create a finder for elements below the reference element. -
near
Create a finder for elements near the reference element. -
intercept
Enable request interception with a handler. The handler is called for each matching request. Return an InterceptResponse to mock, or null to continue to the network.- Specified by:
interceptin interfaceCoreDriver- Specified by:
interceptin interfaceDriver- Parameters:
patterns- URL patterns to intercept (e.g., "*api/*", "https://example.com/*")handler- the intercept handler
-
intercept
Enable request interception for all requests. -
stopIntercept
public void stopIntercept()Stop request interception.- Specified by:
stopInterceptin interfaceDriver
-