Documentation Index
Fetch the complete documentation index at: https://mintlify.com/l-xiaoshen/handstage/llms.txt
Use this file to discover all available pages before exploring further.
Locator is a lazy element handle scoped to a specific Frame. It resolves its selector fresh on every action, so you never deal with stale element references. Locators are created from page.locator(selector) or from frameLocator.locator(selector) for cross-frame access.
CSS selectors, XPath expressions, and text selectors are all supported. The type is detected automatically from the string prefix. XPath is detected when the string starts with / or (. Use an explicit xpath=, css=, or text= prefix to override auto-detection.
Pointer actions
locator.click
Scroll the element into view, resolve its bounding box, and dispatch a mouse press + release at its visual center.
Which mouse button to use.
Number of clicks to dispatch.
Promise<void>
Throws ElementNotVisibleError if the element has no box model (is not rendered). Throws HandstagesElementNotFoundError if the selector matches nothing.
locator.hover
Move the mouse cursor to the element’s visual center without clicking.
Promise<void>
Input actions
locator.fill
Fill an <input>, <textarea>, or contenteditable element with a value. Uses a native value setter where possible; falls back to typed input for elements that require it.
The text to set as the element’s value.
Promise<void>
locator.type
Type text into a focused element character by character. Focuses the element first, then uses Input.insertText (fast, no delay) or synthesizes keyDown/keyUp events per character when a delay is specified.
The text to type into the element.
Milliseconds to wait between each keystroke. When omitted,
Input.insertText is used for efficiency.Promise<void>
locator.selectOption
Select one or more options on a <select> element by value. Returns the values that were actually selected.
One or more option values to select.
Promise<string[]> — the values selected after the operation.
locator.setInputFiles
Set files on an <input type="file"> element. Accepts file paths (local connections) or in-memory payload objects (all connection types).
A single file path, an array of file paths, a single
SetInputFilePayload, or an array of payloads. Pass an empty array to clear the selection.Promise<void>
Throws HandstagesInvalidArgumentError if the target element is not an <input type="file">, or if a remote upload payload exceeds 50 MB.
SetInputFilesArgument type
SetInputFilePayload type
File name including extension (e.g.,
"report.csv").MIME type of the file (e.g.,
"text/csv", "image/png"). Optional; the browser may infer from the name.The file content. Strings are interpreted as base64-encoded data.
Unix timestamp (ms) for the file’s last-modified date. Defaults to the current time when omitted.
Reading element state
locator.textContent
Return the element’s textContent — the raw concatenated text of all descendant nodes.
Promise<string>
locator.innerText
Return the element’s innerText — the layout-aware, visible text, respecting CSS display and visibility.
Promise<string>
locator.innerHtml
Return the element’s innerHTML string.
Promise<string>
locator.inputValue
Return the current value of an <input>, <textarea>, <select>, or contenteditable element.
Promise<string>
locator.isVisible
Return true if the element is attached to the DOM and visible (rough heuristic — not a strict layout check).
Promise<boolean>
locator.isChecked
Return true if the element is a checked <input type="checkbox"> or <input type="radio">. Also considers aria-checked for ARIA widgets.
Promise<boolean>
locator.count
Return the number of DOM nodes matched by the selector.
Promise<number>
locator.centroid
Return the center point of the element’s bounding box in the owning frame’s viewport coordinate space, in CSS pixels.
Promise<{ x: number; y: number }>
Throws ElementNotVisibleError if the element has no box model.
Locator refinement
locator.nth
Return a new locator narrowed to the element at the given zero-based index among all matches. Useful when a selector matches multiple elements.
Zero-based index. Must be a non-negative integer.
Locator
locator.first
Shorthand for locator.nth(0). Returns a locator scoped to the first match.
Locator
Frame access
locator.getFrame
Return the Frame that owns this locator. Useful for performing frame-level operations when you already have a locator reference.
Frame
Visual utilities
locator.highlight
Highlight the element’s bounding box using the CDP Overlay domain. Shows a semi-transparent overlay briefly, then hides it. Useful for visual debugging.
How long to show the highlight, in milliseconds.
RGBA color for the border overlay. Defaults to red with 90% opacity.
RGBA color for the content fill overlay. Defaults to yellow with 20% opacity.
Promise<void>
locator.scrollTo
Scroll the element vertically to a given percentage of its scroll height. For <html> or <body>, scrolls the window instead.
Target scroll position as a percentage (0–100).
Promise<void>
locator.sendClickEvent
Dispatch a DOM click MouseEvent directly on the element without synthesizing real pointer input. Useful for elements that use a click event handler but don’t need hit-testing (for example, hidden elements that are programmatically clickable).
Whether the event bubbles up through the DOM.
Whether the event is cancelable.
Whether the event propagates across shadow DOM boundaries.
Click count detail on the
MouseEvent.Promise<void>
locator.backendNodeId
Return the CDP DOM.BackendNodeId for the resolved element. Useful for identity comparisons at the CDP level without needing to hold a live remote object.
Promise<number>