page
url
is provided, navigates to that URL.content
is provided, creates a new page with that HTML content.url
nor content
is provided, returns the currently active page, if any.url
: URL - The URL to navigate the page to. If specified, the browser will attempt to load this URL.
Example: "https://example.com"
content
: String - HTML content to set for the page. If specified, a new page is created with this content.
This is useful for testing static HTML snippets or pages constructed on-the-fly.
Example: "<html><body><h1>Test Page</h1></body></html>"
options
: PageOptions - Options to configure the page’s behavior and environment.
These include settings for viewport, user agent, geolocation, HTTP headers, JavaScript enablement, and more.
See PageOptions
for detailed configuration.act
act(action: "login", variables: { username: "user", password: "password" })
action
: String! - The name of the action sequence to execute.variables
: JSONObject - A JSON object containing variables to be used within the action sequence.options
: ActOptions - Options to control the execution of the action sequence.addCookies
options
: [CookieOptions]! - An array of cookie objects to add. See CookieOptions
for details.addInitScript
addInitScript(options: { content: "window.customVar = 123;" })
Returns true if the script was successfully scheduled.
options
: AddInitScriptOptions! - Options specifying the script content.addScriptTag
<script>
tag into the page with the desired content or URL.
Can be used to inject custom JavaScript into the current document.
Example: addScriptTag(options: { content: "console.log('Injected');" })
or addScriptTag(options: { url: "https://example.com/script.js" })
Returns true if the script tag was successfully added.
options
: AddScriptTagOptions! - Options for the script tag, such as content, URL, or ID.addStyleTag
<style>
tag into the page with the desired content or URL.
Can be used to inject custom CSS to alter the page’s appearance.
Example: addStyleTag(options: { content: "body { background-color: blue; }" })
Returns true if the style tag was successfully added.
options
: AddStyleTagOptions! - Options for the style tag, such as content or URL.blur
blur(selector: "#myInput")
Returns true if the blur action was successful.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: TimeoutOptions - Options to control the timeout for the operation.check
check(selector: "input[type='checkbox']")
Returns true if the element was successfully checked.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: CheckOptions - Options for the check action, like forcing the action or setting a timeout.clear
clear(selector: "#searchField")
Returns true if the element’s content was successfully cleared.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: ClearOptions - Options for the clear action, such as forcing the action or setting a timeout.clearCookies
options
: ClearCookiesOptions! - Options to specify which cookies to clear (by domain, name, or path). If not provided, all cookies are cleared.clearPermissions
click
click(selector: "button.submit")
Returns true if the click action was successful.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: ClickOptions - Options for the click action, such as button type, click count, delay, or modifiers.dragAndDrop
dragAndDrop(source: { selector: "#item-to-drag" }, target: { selector: "#drop-zone" })
Returns true if the drag-and-drop was successful.
source
: ElementOptions! - Selector options for the source element to drag.target
: ElementOptions! - Selector options for the target element to drop onto.options
: DragAndDropOptions - Options for the drag-and-drop operation, like force or specific positions.emulateMedia
emulateMedia(options: { media: PRINT })
Returns true if media emulation was successfully applied.
options
: EmulateMediaOptions! - Options specifying the media features to emulate.evaluate
evaluate(functionOrPredicate: "() => document.title")
Example with argument: evaluate(functionOrPredicate: "selector => document.querySelector(selector).innerText", arg: "#myElement")
Returns the JSON representation of the function’s return value.
functionOrPredicate
: String! - A string containing the JavaScript function or predicate to execute.
Example: "() => ({ width: window.innerWidth, height: window.innerHeight })"
Example: "element => element.tagName"
(if an element is the context)arg
: JSON - An optional JSON serializable argument to pass to the function.events
extract
extract(instruction: "Extract the product name and price", schema: { type: "object", properties: { name: { type: "string" }, price: { type: "number" } } })
Returns the extracted data as a JSON object.
instruction
: String! - A natural language instruction describing what data to extract.
Example: "Get the user's name and email from the profile page."
schema
: JSONObject! - A JSON schema defining the structure of the data to be extracted.
Example: { "type": "object", "properties": { "productName": { "type": "string" }, "price": { "type": "number" } } }
options
: ExtractOptions - Options for the extraction process, like specifying a root selector or timeout.fill
fill(selector: "#email", value: "test@example.com")
Returns true if the element was successfully filled.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.value
: String! - The value to fill into the input field.options
: FillOptions - Options for the fill action, such as forcing the action or setting a timeout.focus
focus(selector: "input[type='text']")
Returns true if the element was successfully focused.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: TimeoutOptions - Options to control the timeout for the operation.goBack
goBack(options: { waitUntil: LOAD })
Returns true if the navigation was successful.
options
: WaitForOptions - Options for waiting for the navigation to complete, such as timeout or lifecycle event.goForward
goForward(options: { timeout: 5000 })
Returns true if the navigation was successful.
options
: WaitForOptions - Options for waiting for the navigation to complete, such as timeout or lifecycle event.grantPermissions
grantPermissions(permissions: [CAMERA, MICROPHONE])
Returns true if permissions were successfully granted.
permissions
: [Permission]! - An array of permissions to grant. See the Permission enum for available values.options
: GrantPermissionsOptions - Options for granting permissions, such as specifying the origin.highlight
highlight(selector: "div.important-notice")
Returns true if the element was successfully highlighted.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.hover
hover(selector: "ul.menu > li:first-child")
Returns true if the hover action was successful.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: HoverOptions - Options for the hover action, such as modifiers, position, or timeout.pressKey
pressKey(key: "Enter")
Returns true if the key press was successful.
key
: String! - The key to press. For a list of possible keys, refer to MDN documentation on KeyboardEvent.key.
Examples: "a"
, "Enter"
, "F1"
, "Control"
, "Shift+A"
(modifiers are handled by ‘options’ or within the key string for some systems).
For combinations like Ctrl+C, usually use individual presses or type for text.options
: PressKeyOptions - Options for the key press, such as delay.type
type(text: "Hello, world!")
Returns true if the text was successfully typed.
text
: String! - The text to type.options
: TypeOptions - Options for typing, such as inter-character delay.observe
observe(instruction: "Identify all interactive elements in the header.")
Returns an array of Observe objects, each describing an observed element or interaction.
instruction
: String! - A natural language instruction describing what to observe on the page.
Example: "Find all buttons and links in the navigation bar."
options
: ObserveOptions - Options for the observation process, like DOM settle timeout.reload
reload(options: { waitUntil: NETWORK_IDLE })
Returns true if the page reload was successful.
options
: WaitForOptions - Options for waiting for the reload to complete, such as timeout or lifecycle event.scrollIntoView
scrollIntoView(selector: "footer")
Returns true if the scroll action was successful.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: TimeoutOptions - Options to control the timeout for the operation.selectOption
<select>
element.
The element is identified using one of the provided selector strategies.
Options can be selected by value, label, or index.
Example: selectOption(selector: "#country", values: [{ value: "US" }])
Returns true if the options were successfully selected.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.values
: [SelectValueOptions]! - An array of option values to select. Options can be specified by value, label, or index.options
: SelectOptionOptions - Options for the select action, such as forcing the action or setting a timeout.selectText
selectText(selector: "#myInput")
Returns true if the text was successfully selected.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: SelectTextOptions - Options for the text selection, such as forcing the action or setting a timeout.
Note: Specific range selection is not exposed here; it typically selects all text in the matched element.setExtraHTTPHeaders
setExtraHTTPHeaders(headers: { "X-Custom-Header": "MyValue" })
Returns true if the headers were successfully set.
headers
: Headers! - A JSON object representing the headers to set. Keys are header names, values are header values.setGeolocation
setGeolocation(options: { latitude: 37.7749, longitude: -122.4194, accuracy: 100 })
Returns true if the geolocation was successfully set.
options
: GeolocationOptions! - Options specifying the latitude, longitude, and optionally accuracy of the geolocation.setInputFiles
<input type="file">
).
The element is identified using one of the provided selector strategies.
Can be used to simulate file uploads.
Example: setInputFiles(selector: "input[type='file']", files: [{ name: "file.txt", mimeType: "text/plain", data: "SGVsbG8gd29ybGQ=" }])
The data
field should be Base64 encoded content of the file.
Returns true if the files were successfully set.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.files
: [InputFileOptions]! - An array of file objects to set for the input. Each file needs a name, mimeType, and base64 encoded data.setOffline
setOffline(enabled: true)
Returns true if the offline status was successfully set.
enabled
: Boolean! - Whether to enable (true) or disable (false) offline mode.setViewport
setViewport(viewport: { width: 1280, height: 720 })
Returns true if the viewport was successfully set.
viewport
: ViewportOptions! - The viewport dimensions (width and height) to set.tap
tap(selector: "button.mobile-menu")
Returns true if the tap action was successful.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: TapOptions - Options for the tap action, such as modifiers, position, or timeout.touch
tap
.
Example: touch(target: { x: 100, y: 200 })
Returns true if the touch action was successful.
target
: PointOptions! - The target coordinates (x, y) for the touch action.uncheck
uncheck(selector: "input[name='subscribe']")
Returns true if the element was successfully unchecked.
selector
: String - The CSS selector for the element. Example: "#username"
for <input id="username" />
.text
: String - Finds an element by its text content. Example: "Login"
for <button>Login</button>
.role
: ARIARole - Finds an element by its ARIA role. Example: "button"
for <div role="button">Submit</div>
.label
: String - Finds an element by its ARIA label. Example: "Search button"
for <button aria-label="Search button"><svg/></button>
.placeholder
: String - Finds an element by its placeholder text. Example: "Enter your email"
for <input placeholder="Enter your email" />
.altText
: String - Finds an element by its image alt text. Example: "Company logo"
for <img alt="Company logo" src="..." />
.title
: String - Finds an element by its title attribute. Example: "Close dialog"
for <span title="Close dialog">X</span>
.testId
: String - Finds an element by its data-testid attribute. Example: "submit-button"
for <button data-testid="submit-button">Go</button>
.filter
: ElementFilterOptions - Advanced filtering options for the element.options
: CheckOptions - Options for the uncheck action, similar to check options.waitForEvent
LOAD
, REQUEST
, or CONSOLE
.
Example: waitForEvent(event: LOAD, options: { timeout: 10000 })
Returns true if the event occurred within the timeout.
event
: PageEvent - The page event to wait for. See the PageEvent enum for available values.options
: TimeoutOptions - Options for waiting, such as timeout.waitForFunction
waitForFunction(functionOrPredicate: "() => window.myAppInitialized === true")
Returns true if the function returns truthy within the timeout.
functionOrPredicate
: String! - A string containing the JavaScript function or predicate to evaluate.
It should return a truthy value when the condition is met.
Example: "() => document.querySelector('#dynamicElement') !== null"
arg
: JSON - An optional JSON serializable argument to pass to the function.options
: WaitForFunctionOptions - Options for waiting, such as polling interval and timeout.waitForLoadState
DOM_CONTENT_LOADED
or NETWORK_IDLE
.
Example: waitForLoadState(state: NETWORK_IDLE)
Returns true if the load state was reached within the timeout.
state
: LoadState! - The load state to wait for. See the LoadState enum for available values.options
: TimeoutOptions - Options for waiting, such as timeout.waitForRequest
waitForRequest(urlOrPredicate: "**/api/data")
Returns true if a matching request occurred within the timeout.
urlOrPredicate
: String! - A URL string, glob pattern, or JavaScript predicate string to match against request URLs.
Example: "https://example.com/resource.js"
or "**/*.css"
options
: TimeoutOptions - Options for waiting, such as timeout.waitForResponse
waitForResponse(urlOrPredicate: "https://api.example.com/user")
Returns true if a matching response occurred within the timeout.
urlOrPredicate
: String! - A URL string, glob pattern, or JavaScript predicate string to match against response URLs.
Example: "https://example.com/data.json"
options
: TimeoutOptions - Options for waiting, such as timeout.waitForURL
waitForURL(urlOrPredicate: "**/profile/**", options: { waitUntil: LOAD })
Returns true if the URL matches within the timeout and wait conditions.
urlOrPredicate
: String! - A URL string, glob pattern, or JavaScript predicate string to match against the page URL.
Example: "https://example.com/dashboard"
or "**/login?success=true"
options
: WaitForOptions - Options for waiting, such as timeout and lifecycle event to wait for.