Interacting
BrowserQL is our first-class browser automation API, and includes powerful options like human-like, reconnecting and proxying. It's a full rethink of how to do browser automation with a minimalistic stealth-first approach. In order to get started, you'll need to sign-up for a cloud plan and get your API Key as well as our Desktop editor -- all of which are available via the account portal.
Interactions
Many cases for gathering data or normalizing data across systems require you click, type and submit forms. All of these are staples of any web automation library and are supported by BrowserQL.
By default, BrowserQL takes care of waiting for these elements to be present in the document, visible to an end user, and scrolls to them in the viewport. You won't have to worry about writing code to handle those small nuanced situations.
For instance, clicking a button cloud look like:
mutation ClickButton {
# ... Navigate to your site of choice, then click and return x, y positions
click(selector: "button[data-automation-id='atc']", visible: true) {
x
y
}
}
In this example we click on a <Button>
element with a data-attribute of data-automation-id="atc"
. We're also specifying visible
to true
as well, meaning the element can't be offscreen or otherwise invisible to the user.
By default BrowserQL will automatically wait for elements to be present before interacting with them. You can limit the amount of time it will wait by setting a timeout
argument:
Pro-tip: Set "human-like" behavior in the session settings for smoother mouse movements and small delays.
mutation ClickButton {
click(
selector: "button[data-automation-id='atc']"
visible: true
timeout: 10000
) {
x
y
}
}
This will limit the timeout
to 10 seconds versus the default of 30 seconds
.
Keyboard and Typing
BrowserQL also supports typing as well similar to how the click
query works. By specifying text
and a selector`, you can instruct a browser to type fairly easily:
mutation TypeInteraction {
type(
text: "I'm a little teapot!"
selector: "form textarea"
) {
x
y
}
}
By default, BrowserQL will type a character at a time with a random interval of space between similar to a real user. If you wish to change this delay you can specify a min and max delay:
mutation TypeInteraction {
type(
text: "I'm a little teapot!"
selector: "form textarea"
delay: [10, 50]
) {
x
y
}
}
This means a delay between 10
and 50
milliseconds is chosen at random between keystrokes. You can further enhance this with "human-like" in your sessions's settings.
More interactions
You can also toggle check-boxes, radio-boxes and select elements as well with BrowserQL. Refer to the Editors built-in documentation for more details on those types of queries!