Actions5
Overview
This node integrates with the Browserless API to perform browser automation tasks such as executing custom JavaScript code in a browser context, scraping content, capturing screenshots, and generating PDFs. Specifically, for the Function - Execute operation, it allows users to run arbitrary JavaScript code within a browser environment managed by Browserless. This is useful for scenarios where you need to interact programmatically with web pages, manipulate DOM elements, or extract data dynamically using custom scripts.
Practical examples include:
- Running complex page interactions that require JavaScript execution.
- Extracting data from dynamic websites that rely heavily on client-side rendering.
- Automating form submissions or navigation flows.
- Testing or debugging web page behavior by injecting custom scripts.
Properties
Name | Meaning |
---|---|
Code | The JavaScript code snippet to be executed inside the browser context. |
Context | A JSON object representing the context or variables passed into the script execution environment. |
Detached | Boolean flag indicating whether the browser session should run detached (independently) from the workflow. |
Browser Options | Collection of optional settings to customize browser behavior: |
- BlockAds | Whether to block advertisement network traffic (true/false). |
- Headless | Whether the browser runs in headless mode (no UI) (true/false). |
- Ignore HTTPS Errors | Whether to ignore HTTPS errors during page loads and network calls (true/false). |
- Stealth | Enables stealth mode to help avoid bot detection (true/false). |
- User Data Dir | Path to reuse previous session data like cookies and local storage (string). |
- TrackingId | Arbitrary tracking ID for correlating sessions or API calls (string). |
- Keep Alive | Time in milliseconds to keep the browser running after the session ends (string). |
- Flags | Command-line flags passed directly to Chrome on startup (string). |
Output
The output contains a json
field with the result of the executed JavaScript code returned from the Browserless API. The structure depends on what the executed code returns but generally includes the evaluation result or any data produced by the script.
No binary data is output for this operation.
Example output JSON might look like:
{
"result": { /* result of the executed code */ }
}
Dependencies
- Requires an active connection to the Browserless API service.
- Needs an API key credential configured in n8n to authenticate requests to Browserless.
- Network access to the Browserless endpoint (
https://chrome.rowserless.io
) must be available.
Troubleshooting
Common issues:
- Invalid or malformed JavaScript code in the "Code" property can cause execution errors.
- Incorrectly formatted JSON in the "Context" property will cause parsing failures.
- Network connectivity problems or invalid API credentials will prevent communication with Browserless.
- Using detached mode without proper handling may lead to orphaned browser sessions.
Error messages:
"SyntaxError"
or similar indicates issues in the provided JavaScript code."Failed to parse context JSON"
suggests invalid JSON input in the Context field.- Authentication errors indicate missing or incorrect API keys.
Resolutions:
- Validate and test JavaScript code snippets independently before use.
- Ensure JSON context is well-formed.
- Verify API credentials and network connectivity.
- Use detached mode only when necessary and monitor browser sessions accordingly.