Skip to main content

click

Waits for the element to be visible, scrolls to it, then clicks on it with native events

Example:

mutation ClickButton {
goto(url: "https://example.com") {
status
}

click(selector: "a") {
time
}
}
click(
selector: String!
scroll: Boolean = true
timeout: Float
visible: Boolean = false
wait: Boolean = true
): ClickResponse

Arguments

click.selector ● String! non-null scalar

A query-selector compatible string, JavaScript that returns an HTML Node, OR a Browserless-deep query. Examples include:

  • A simple <button /> Element: selector: "button"

  • A JavaScript snippet that returns a button element selector: "document.querySelector('button')"

  • A Browserless Deep query. These queries must start with a "<" character. Deep queries will traverse all iframes, shadow-doms (open or closed), and more. Basic deep query: selector: "< button"

Advanced deep query features:

  • URL Pattern Matching: Target elements within specific iframes using glob patterns selector: "< https://example.com/* button.active" selector: "< *google.com/recaptcha* #recaptcha-anchor"

  • Complex Selectors: Combine multiple attributes, classes, and IDs selector: "< input#username.login-form[type='text'][data-test-id*='user']"

  • Attribute Matching: Use various attribute matching operators

    • Contains (*): [data-test*="partial"]
    • Starts with (^): [class^="prefix-"]
    • Ends with ($): [id$="-suffix"]
    • Exact match: [type="submit"]
    • Presence only: [required]
  • Class and ID Combinations: selector: "< button#submit.primary.large[data-action='save']"

For reCAPTCHA interactions, you can use deep selectors to target elements within the reCAPTCHA iframe: selector: "< *google.com/recaptcha* #recaptcha-anchor"

Note: Deep selectors support standard CSS selector syntax while maintaining security by disallowing potentially dangerous characters and patterns.

click.scroll ● Boolean scalar

Whether or not to scroll to the element prior to clicking, defaults to true

click.timeout ● Float scalar

How long to wait for the element to appear before timing out on the click handler, overriding any defaults. Default timeout is 30 seconds, or 30000.

click.visible ● Boolean scalar

Whether or not to click the element only if it's visible

click.wait ● Boolean scalar

Whether or not to wait for the element to present in the DOM

Type

ClickResponse object

Response returned after having clicked on an element