Skip to main content
Version: v2

Mutations

This page presents reference for all available mutations.

Back

Moves back in the browser history, optionally accepting parameters for waitUntil and timeout. Returns null if no back navigation is possible.

back(
waitUntil: WaitUntilHistory = commit
timeout: Float
): HTTPResponse
ArgumentTypeDescription
waitUntilWaitUntilHistoryWhen to consider the page fully loaded and proceed with further execution. Defaults to commit.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the page to load, overriding any defaults.

Response: HTTPResponse

Checkbox

Checks or unchecks a checkbox input element.

checkbox(
selector: String!
checked: Boolean!
wait: Boolean = true
scroll: Boolean = true
visible: Boolean = false
timeout: Float
): ClickResponse
ArgumentTypeDescription
selectorString!The CSS selector of the checkbox element to check/uncheck.
checkedBoolean!Whether the checkbox input should be checked or unchecked.
waitBoolean = trueWhether to wait for the checkbox element to be present in the DOM.
scrollBoolean = trueWhether to scroll to the checkbox element before clicking. Defaults to true.
visibleBoolean = falseWhether to check/uncheck the checkbox only if it is visible.
timeoutFloatHow long to wait for the element to appear before timing out, overriding any defaults.

Response: ClickResponse

Click

Waits for the element to be visible, scrolls to it if needed, and clicks on it using native events.

click(
selector: String!
wait: Boolean = true
scroll: Boolean = true
visible: Boolean = false
timeout: Float
): ClickResponse
ArgumentTypeDescription
selectorString!A query-selector compatible string, JavaScript that returns an HTML Node, or a Browserless-deep query. Examples include:
- A simple <button /> element: "button".
- A JavaScript snippet returning a button element: "document.querySelector('button')"
- A Browserless deep query, starting with < for traversing iframes, shadow DOMs, etc.: "< button"
waitBoolean = trueWhether to wait for the element to be present in the DOM.
scrollBoolean = trueWhether to scroll to the element before clicking. Defaults to true.
visibleBoolean = falseWhether to click the element only if it's visible.
timeoutFloatHow long to wait for the element to appear before timing out, overriding defaults.

Response: ClickResponse

Content

Sets the given HTML content on the page with an optional waitUntil parameter.

content(
html: String!
waitUntil: WaitUntilHistory
): HTTPResponse
ArgumentTypeDescription
htmlString!Sets the content of the page to the provided HTML value, then returns the page's content.
waitUntilWaitUntilHistoryWhen to consider the page fully loaded and proceed with further execution.

Response: HTTPResponse

Cookies

Sets and gets cookies on the page.

cookies(
cookies: [CookieInput]
): CookieResponse
ArgumentTypeDescription
cookies[CookieInput]The cookies to set on the page.

Response: CookieResponse

Evaluate

Evaluates JavaScript in the browser's page environment, using either raw content or a URL pointing to the script.

evaluate(
content: String
url: String
timeout: Float
): EvaluateResponse
ArgumentTypeDescription
contentStringThe raw JavaScript code to evaluate. Wrapped in an async function, allowing return, await, and other async concepts. Returns any stringified value.
urlStringThe URL of the JavaScript script to evaluate. Wrapped in an async function, allowing return, await, and other async concepts. Returns any stringified value.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the script to finish evaluating, overriding defaults. Useful for longer-running async scripts.

Response: EvaluateResponse

Forward

Moves forward in the browser history, optionally accepting parameters for waitUntil and timeout. Returns null if no forward navigation is possible.

forward(
waitUntil: WaitUntilHistory = commit
timeout: Float
): HTTPResponse
ArgumentTypeDescription
waitUntilWaitUntilHistoryWhen to consider the page fully loaded and proceed with further execution. Defaults to commit.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the page to load, overriding any defaults.

Response: HTTPResponse

Goto

Navigates to a URL with optional parameters for waitUntil and timeout.

goto(
url: String!
waitUntil: WaitUntilGoto = commit
timeout: Float
): HTTPResponse
ArgumentTypeDescription
urlString!The fully-qualified URL of the page you'd like to navigate to.
waitUntilWaitUntilGotoWhen to consider the page fully loaded and proceed with further execution. Defaults to commit.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the page to load, overriding any defaults.

Response: HTTPResponse

HTML

Returns the HTML content of the page or a specified selector.

html(
selector: String
visible: Boolean = false
timeout: Float
): HTMLResponse
ArgumentTypeDescription
selectorStringThe DOM selector of the element whose HTML content you want to retrieve.
visibleBoolean = falseWhether to return the HTML content of the element only if it's visible.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the selector to appear, overriding defaults.

Response: HTMLResponse

Hover

Waits for the element to be visible, scrolls to it if needed, and hovers over it using native events.

hover(
selector: String
x: Float
y: Float
wait: Boolean = true
scroll: Boolean = true
visible: Boolean = false
timeout: Float
): HoverResponse
ArgumentTypeDescription
selectorStringThe CSS selector of the element on the page you want to hover on.
xFloatThe x-coordinate, in pixels, to hover on the page.
yFloatThe y-coordinate, in pixels, to hover on the page.
waitBoolean = trueWhether to wait for the element to be present in the DOM.
scrollBoolean = trueWhether to scroll to the element before hovering. Defaults to true.
visibleBoolean = falseWhether to hover on the element only if it's visible.
timeoutFloatHow long to wait for the element to appear before timing out, overriding any defaults.

Response: HoverResponse

If

Triggers a nested branch of work when a given condition is true. This method performs a point-in-time check and does not wait for the conditions to be met. Use the wait method for awaiting specific behaviors.

if(
selector: String
visible: Boolean = false
request: RequestInput
response: ResponseInput
): Mutation
ArgumentTypeDescription
selectorStringTriggers the subsequent conditions if the selector is immediately present.
visibleBoolean = falseDetermines whether to consider the selector visible within the viewport when evaluating conditions.
requestRequestInputTriggers the nested conditions if a request has been made with the specified conditions.
responseResponseInputTriggers the nested conditions if a response has been received with the specified conditions.

IfNot

Triggers a nested branch of work when a given condition is false. This method performs a point-in-time check and does not wait for the conditions to be met. Use the wait method for awaiting specific behaviors.

ifnot(
selector: String
request: RequestInput
response: ResponseInput
): Mutation
ArgumentTypeDescription
selectorStringTriggers the subsequent conditions if the selector is immediately present.
requestRequestInputTriggers the nested conditions if a request has been made with the specified conditions.
responseResponseInputTriggers the nested conditions if a response has been received with the specified conditions.

JavaScriptEnabled

Sets and gets JavaScript execution on the page.

javaScriptEnabled(
enabled: Boolean
): JavaScriptResponse
ArgumentTypeDescription
enabledBooleanWhether or not to enable JavaScript on the page.

Response: JavaScriptResponse

PDF

Generates a PDF of the page with customizable formatting and layout options.

pdf(
format: PDFPageFormat
landscape: Boolean
displayHeaderFooter: Boolean
printBackground: Boolean
scale: Float
width: FloatOrString
height: FloatOrString
marginTop: FloatOrString
marginBottom: FloatOrString
marginLeft: FloatOrString
marginRight: FloatOrString
pageRanges: String
headerTemplate: String
footerTemplate: String
preferCSSPageSize: Boolean
transferMode: String
generateTaggedPDF: Boolean
generateDocumentOutline: Boolean
): PDFResponse
ArgumentTypeDescription
formatPDFPageFormatThe page format to use for the PDF.
landscapeBooleanPaper orientation. Defaults to false.
displayHeaderFooterBooleanDisplay header and footer. Defaults to false.
printBackgroundBooleanPrint background graphics. Defaults to false.
scaleFloatScale of the webpage rendering. Defaults to 1.
widthFloatOrStringWidth in inches or CSS unit. Defaults to 8.5 inches.
heightFloatOrStringHeight in inches or CSS unit. Defaults to 11 inches.
marginTopFloatOrStringTop margin in inches or CSS unit. Defaults to 1cm (~0.4 inches).
marginBottomFloatOrStringBottom margin in inches or CSS unit. Defaults to 1cm (~0.4 inches).
marginLeftFloatOrStringLeft margin in inches or CSS unit. Defaults to 1cm (~0.4 inches).
marginRightFloatOrStringRight margin in inches or CSS unit. Defaults to 1cm (~0.4 inches).
pageRangesStringPaper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to an empty string (entire document).
headerTemplateStringHTML template for the print header. Supports specific classes for printing values.
footerTemplateStringHTML template for the print footer. Supports specific classes for printing values.
preferCSSPageSizeBooleanWhether to prefer page size defined by CSS. Defaults to false.
transferModeStringReturn as stream (PrintToPDFRequestTransferMode enum).
generateTaggedPDFBooleanWhether to generate tagged (accessible) PDF. Defaults to embedder choice.
generateDocumentOutlineBooleanWhether to embed the document outline into the PDF.

Response: PDFResponse

Preferences

Sets configuration for the entirety of the session, replacing defaults like the 30-second timeout default.

preferences(timeout: Float): DefaultResponse
ArgumentTypeDescription
timeoutFloatSets a default timeout for all methods, including goto, type, wait, etc.

Response: DefaultResponse

QuerySelector

Passes through certain properties of the browser's native querySelector API.

querySelector(
selector: String!
timeout: Float
visible: Boolean = false
): QuerySelectorResponse
ArgumentTypeDescription
selectorString!The CSS selector to query for in the DOM.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the selector to appear, overriding defaults.
visibleBoolean = falseWhether to query only elements that are visible.

Response: QuerySelectorResponse

QuerySelectorAll

Passes through certain properties of the browser's native querySelectorAll API.

querySelectorAll(
selector: String!
timeout: Float
visible: Boolean = false
): [QuerySelectorResponse]
ArgumentTypeDescription
selectorString!The CSS selector to query for in the DOM.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the selector to appear, overriding defaults.
visibleBoolean = falseWhether to query only elements that are visible.

Response: [QuerySelectorResponse]

Reconnect

Returns a payload with reconnection information to reconnect back to the same browser session.

reconnect(
timeout: Float = 30000
): ReconnectionResponse
ArgumentTypeDescription
timeoutFloat = 30000The amount of time, in milliseconds, to leave the browser open without a connection before it is manually terminated. Defaults to 30 seconds.

Response: ReconnectionResponse

Reload

Reloads the given page with optional parameters for waitUntil and timeout.

reload(
waitUntil: WaitUntilHistory = commit
timeout: Float
): HTTPResponse
ArgumentTypeDescription
waitUntilWaitUntilHistoryWhen to consider the page fully loaded and proceed with further execution. Defaults to commit.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the page to load, overriding any defaults.

Response: HTTPResponse

Screenshot

Takes a screenshot of the page or a specific selector.

screenshot(
selector: String
captureBeyondViewport: Boolean
clip: ScreenshotClip
fromSurface: Boolean
fullPage: Boolean
omitBackground: Boolean
optimizeForSpeed: Boolean
quality: Float
type: ScreenshotType
): ScreenshotResponse
ArgumentTypeDescription
selectorStringThe CSS selector of the element on the page to screenshot.
captureBeyondViewportBooleanCaptures the screenshot beyond the viewport. Defaults to False unless clip is specified.
clipScreenshotClipSpecifies the region of the page or element to clip for the screenshot.
fromSurfaceBooleanCaptures the screenshot from the surface, rather than the view. Defaults to True.
fullPageBooleanCaptures a screenshot of the full page. Defaults to False.
omitBackgroundBooleanHides the default white background for transparent screenshots. Defaults to False.
optimizeForSpeedBooleanOptimizes image encoding for speed instead of resulting size. Defaults to False.
qualityFloatSpecifies image quality, between 0-100. Not applicable for PNG images.
typeScreenshotTypeThe final format of the screenshot.

Response: ScreenshotResponse

Scroll

Waits for a selector and then scrolls to it on the page or to a specified x, y coordinate in pixels.

scroll(
selector: String
x: Float
y: Float
wait: Boolean = true
visible: Boolean = false
timeout: Float
): ScrollResponse
ArgumentTypeDescription
selectorStringThe DOM selector of the element on the page to scroll to.
xFloatThe x-coordinate, in pixels, to scroll to.
yFloatThe y-coordinate, in pixels, to scroll to.
waitBoolean = trueWhether to wait for the element before scrolling to it.
visibleBoolean = falseWhether to scroll to the element only if it's visible.
timeoutFloatHow long to wait for the element to appear before timing out, overriding defaults.

Response: ScrollResponse

Select

Selects a value from a dropdown or multiple select element.

select(
selector: String!
value: StringOrArray!
wait: Boolean = true
scroll: Boolean = true
visible: Boolean = false
timeout: Float
): SelectResponse
ArgumentTypeDescription
selectorString!The CSS selector of the element to select a value from.
valueStringOrArray!The value or values to select from the dropdown or multiple select element.
waitBoolean = trueWhether to wait for the select element to be present in the DOM.
scrollBoolean = trueWhether to scroll to the select element before selecting a value. Defaults to true.
visibleBoolean = falseWhether to select a value only if the element is visible.
timeoutFloatHow long to wait for the element to appear before timing out, overriding any defaults.

Response: SelectResponse

Solve

🚨 EXPERIMENTAL 🚨
Solves a captcha or other challenge, specified by the "type" of captcha to solve.

solve(
type: CaptchaTypes!
wait: Boolean = true
timeout: Float
): CaptchaResponse
ArgumentTypeDescription
typeCaptchaTypes!An enum specifying the type of captcha to look for and solve.
waitBoolean = trueWhether to wait for the captcha to be present on the page.
timeoutFloatThe time, in milliseconds, to wait for a captcha to appear. Only valid when wait = true.

Response: CaptchaResponse

Text

Returns the text content of the page or a specified selector.

text(
selector: String
visible: Boolean = false
timeout: Float
): TextResponse
ArgumentTypeDescription
selectorStringThe DOM selector of the element whose text content you want to retrieve.
visibleBoolean = falseWhether to return the text content of the element only if it's visible.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the selector to appear, overriding defaults.

Response: TextResponse

Title

Returns the title of the page that the browser is currently at.

title: TitleResponse

Response: TitleResponse

Type

Types text into an element by scrolling to it, clicking it, and emitting key events for each character.

type(
text: String!
selector: String!
delay: [Int] = [50, 200]
wait: Boolean = true
scroll: Boolean = true
visible: Boolean = false
interactable: Boolean = true
timeout: Float
): TypeResponse
ArgumentTypeDescription
textString!The text content to type into the element.
selectorString!The CSS selector of the element where the text will be typed.
delay[Int] = [50, 200]The delay between keystrokes, in milliseconds. Values are used as a range and chosen at random.
waitBoolean = trueWhether to wait for the element to be present in the DOM.
scrollBoolean = trueWhether to scroll to the element before typing. Defaults to true.
visibleBoolean = falseWhether to type into the element only if it's visible.
interactableBoolean = trueWhether to check if the element is interactable by hovering over it and confirming its availability.
timeoutFloatHow long to wait for the element to appear before timing out, overriding defaults.

Response: TypeResponse

URL

Returns the URL of the page that the browser is currently at.

url: URLResponse

Response: URLResponse

Verify

🚨 EXPERIMENTAL 🚨
Clicks a verification button to assert human-like interaction.

verify(
type: VerifyTypes!
wait: Boolean = true
timeout: Float
): CaptchaResponse
ArgumentTypeDescription
typeVerifyTypes!An enum specifying the type of verification to look for and interact with.
waitBoolean = trueWhether to wait for the verification to be present on the page.
timeoutFloatThe time, in milliseconds, to wait for a verification to appear. Only valid when wait = true.

Response: CaptchaResponse

WaitForNavigation

Waits for a navigation event to occur, typically used when clicking an element and waiting for a page load.

waitForNavigation(
waitUntil: WaitUntilGoto = commit
timeout: Float
): HTTPResponse
ArgumentTypeDescription
waitUntilWaitUntilGotoWhen to consider the page fully loaded and proceed with further execution. Defaults to commit.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the page to load, overriding any defaults.

Response: HTTPResponse

WaitForRequest

Waits for the browser to make a particular request.

waitForRequest(
url: String
method: Method
timeout: Float
): WaitForRequest
ArgumentTypeDescription
urlStringThe pattern of the request URL to wait for, using glob-style pattern-matching.
methodMethodThe HTTP method of the request to wait for.
timeoutFloatHow long to wait for the request to be made before timing out, overriding any defaults.

Response: WaitForRequest

WaitForResponse

Waits for a specific network response to be made back to the browser.

waitForResponse(
url: String
codes: [Int]
): WaitForResponse
ArgumentTypeDescription
urlStringThe pattern of the response URL to wait for, using glob-style pattern-matching.
codes[Int]The HTTP response code(s) to wait for. Can be a single HTTP code or a list of desired codes.

Response: WaitForResponse

WaitForSelector

Waits for a given selector to be present in the DOM, with an optional visibility check.

waitForSelector(
selector: String!
visible: Boolean = false
timeout: Float
): WaitForSelector
ArgumentTypeDescription
selectorString!The selector to wait for until it is present in the DOM.
visibleBoolean = falseWhether to consider the element as present only if it's visible.
timeoutFloatThe maximum amount of time, in milliseconds, to wait for the selector to appear, overriding defaults.

Response: WaitForSelector

WaitForTimeout

Waits for a specific period of time, defined in milliseconds.

waitForTimeout(
time: Float!
): WaitForTimeout
ArgumentTypeDescription
timeFloat!The amount of time to wait for, in milliseconds.

Response: WaitForTimeout