Tasks
Virtual Worker Send Commands
Executes a set of virtual worker commands to perform automated actions
See virtual-worker concept for more details.
This task and the virtual worker concept are still in active development and may change in the future.
The parameters and available commands might be updated frequently.
Basic usage
Run a virtual worker that navigates to a website and types text into a field.
Parameters
timeout_seconds optional number
The seconds after which the virtual_worker_send_commands task will time out.
This is also used as the timeout for starting a new worker inside a cluster, specifically timeout_seconds - 10, to allow for actual command execution before the overall task timeout.
Default: 300
runtime Object required
Defines the execution settings for the virtual worker.
Show child attributes
cluster Object
Show child attributes
name string optional
The name of the cluster where the virtual worker will be executed.
Default: stubber_k8s_cluster
worker Object
Defines settings for the containerized virtual worker.
Show child attributes
name string optional
The name of the virtual worker to use for executing the commands.
Can be used to run commands on a specific container inside the cluster.
Default: {{stub.stubref}}
worker_spec Object
Show child attributes
idle_timeout_minutes number optional
The number of minutes the virtual worker will remain idle before automatically shutting down.
Default: 30 minutes
cpu_request string optional
The amount of CPU requested for the virtual worker container.
Default: 128m
cpu_limit string optional
The maximum amount of CPU the virtual worker container can use.
Default: 1024m
memory_request string optional
The amount of memory requested for the virtual worker container.
Default: 128Mi
memory_limit string optional
The maximum amount of memory the virtual worker container can use.
Default: 1024Mi
commands Object required
A set of commands to execute by the virtual worker.
Each command is defined as a key-value pair, where the key is a unique identifier for the command, and the value is an object defining the command type and its parameters. See more below.
IMPORTANT :
Each command must have a unique __order parameter to define the execution order.
Browser Commands
slow_mo optional number
Every browser command below accepts an optional <command>.params.slow_mo parameter that defines a delay in milliseconds between each action performed by the browser.
Useful for debugging or visualizing the actions being performed.
Needs to be set on the first command to take effect for the entire browser session.
Browser Write text
Will write the specified text into the element located by the locator.
Browser Navigate
Will navigate the browser to the specified URL.
Browser Click
Will click on the element located by the locator.
Browser Press Key
Will press the specified key in the focused element.
Browser Get Local Storage
Will retrieve the entire local storage of the browser. Depends on the website what data is stored there.
Browser Extract Data
Will extract data from the page using the specified locators.
Converts HTML elements into structured JSON data.
Specifying a string as the value of a locator will extract the text content of the element.
Specifying an object as the value of a locator allows for more complex extraction, including lists and attributes.
To extract a list of elements, use the special key _list with a locator string that will match multiple elements.
To extract properties of each list item, use the special key _list_item_properties with an object defining the properties to extract.
To extract an attribute of an element, use the special keys _locator and _target within a locator object.
Browser Screenshot
Will take a screenshot of the current page or of the given locator.
params.locator (optional): A locator string to capture a specific element's screenshot.
params.screenshot_options (optional) parameter can be used to specify additional options for the screenshot.
Supports all options from Playwright's page.screenshot() method.
Notably:
fullPage(boolean): When true, takes a screenshot of the full scrollable page. Default is false.clip(object): An object specifying the clipping region of the screenshot with propertiesx,y,width, andheight.
Returns
Browser Extract HTML
Will extract the HTML content of the current page or of the given locator.
params.locator (optional): A locator string to extract HTML from a specific element.
Returns
Locators
Locators are used to identify and interact with elements on a web page. They can be defined using various strategies, such as CSS selectors, XPath expressions, or text content. See locators documentation for more details and examples.
Browser Session Management
params.session_id (string, optional) parameter can be provided to maintain a persistent browser session across multiple commands.
If provided, the virtual worker will maintain a persistent browser session associated with that session ID.
Default: {{stub.stubref}}
File Server Commands
Download Files
Integrates with the Stubber file storage system to download files by their UUIDs.
Specify either an array of strings (fileuuids) or an array of objects with a fileuuid property.
Files are downloaded to the default tmp directory on the virtual worker machine.
Upload Files
Uploads files from the virtual worker machine to the Stubber file storage system.
Specify an array of file paths to be uploaded.
Resulting fileuuids are available in the command payload if successful.
CLI Command
You can also execute arbitrary CLI commands on the virtual worker.
Run CLI Command
params.command (string, required): The CLI command to execute on the virtual worker.
Returns
Available Libraries
The following libraries are pre-installed and can be used in CLI commands:
- curl
- unzip
- tree
Python Libraries
The following Python libraries are pre-installed and can be used in python scripts:
- pandas
- openpyxl
- odfpy
- numpy
- xlsxwriter
To use python, simply write a script and execute it via the cli_run command. For example: