execute-browser-commands
Execute predefined browser commands such as clicking, typing, scrolling, and navigating through a sequence of actions to automate web interactions safely and efficiently.
Instructions
Executes a sequence of predefined browser commands safely. Available commands:
- click: Clicks on an element matching the selector or at specified coordinates
- type: Types text into an input element
- wait: Waits for an element, a specified time period, or a condition
- navigate: Navigates to a specified URL
- select: Selects an option in a dropdown
- check: Checks or unchecks a checkbox
- hover: Hovers over an element
- focus: Focuses an element
- blur: Removes focus from an element
- keypress: Simulates pressing a keyboard key
- scroll: Scrolls the page or an element
- getAttribute: Gets an attribute value from an element
- getProperty: Gets a property value from an element
- drag: Performs a drag operation from one position to another
- refresh: Refreshes the current page
Note on coordinates: For all mouse-related commands (click, drag, etc.), coordinates are relative to the browser viewport where (0,0) is the top-left corner. X increases to the right, Y increases downward.
Examples are available in the schema definition.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
commands | Yes | Array of commands to execute in sequence | |
timeout | No | Overall timeout in milliseconds (default: 30000) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"commands": {
"description": "Array of commands to execute in sequence",
"items": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"button": {
"description": "Mouse button to use (default: left)",
"enum": [
"left",
"right",
"middle"
],
"type": "string"
},
"clickCount": {
"description": "Number of clicks (default: 1)",
"type": "number"
},
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"delay": {
"description": "Delay between mousedown and mouseup in ms (default: 0)",
"type": "number"
},
"x": {
"description": "X coordinate to click (used instead of selector)",
"type": "number"
},
"y": {
"description": "Y coordinate to click (used instead of selector)",
"type": "number"
}
},
"required": [
"y"
],
"type": "object"
},
"command": {
"const": "click",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element to click (required unless x,y coordinates are provided)",
"type": "string"
}
},
"required": [
"command"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"clearFirst": {
"description": "Whether to clear the input field before typing (default: false)",
"type": "boolean"
},
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"delay": {
"description": "Delay between keystrokes in ms (default: 0)",
"type": "number"
},
"text": {
"description": "Text to type into the element",
"type": "string"
}
},
"required": [
"text"
],
"type": "object"
},
"command": {
"const": "type",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of input element to type into",
"type": "string"
}
},
"required": [
"command",
"selector"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"time": {
"description": "Time to wait in milliseconds (use this or selector)",
"type": "number"
},
"timeout": {
"description": "Maximum time to wait in ms (default: 5000)",
"type": "number"
},
"visible": {
"description": "Wait for element to be visible (default: true)",
"type": "boolean"
}
},
"type": "object"
},
"command": {
"const": "wait",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector to wait for",
"type": "string"
}
},
"required": [
"command"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"url": {
"description": "URL to navigate to",
"type": "string"
},
"waitUntil": {
"description": "Navigation wait condition (default: networkidle0)",
"enum": [
"load",
"domcontentloaded",
"networkidle0",
"networkidle2"
],
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
},
"command": {
"const": "navigate",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
}
},
"required": [
"command",
"args"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"offsetX": {
"description": "Horizontal distance to drag (positive for right, negative for left)",
"type": "number"
},
"offsetY": {
"description": "Vertical distance to drag (positive for down, negative for up)",
"type": "number"
},
"smoothDrag": {
"description": "Whether to perform a smooth, gradual drag movement (default: false)",
"type": "boolean"
},
"sourceX": {
"description": "X coordinate to start the drag from (distance from left edge of viewport)",
"type": "number"
},
"sourceY": {
"description": "Y coordinate to start the drag from (distance from top edge of viewport)",
"type": "number"
},
"steps": {
"description": "Number of intermediate steps for smooth drag (default: 10)",
"type": "number"
}
},
"required": [
"sourceX",
"sourceY",
"offsetX",
"offsetY"
],
"type": "object"
},
"command": {
"const": "drag",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
}
},
"required": [
"command",
"args"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"value": {
"description": "Value of the option to select",
"type": "string"
}
},
"required": [
"value"
],
"type": "object"
},
"command": {
"const": "select",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of select element",
"type": "string"
}
},
"required": [
"command",
"selector",
"args"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"checked": {
"description": "Whether to check or uncheck the box (default: true)",
"type": "boolean"
},
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
}
},
"type": "object"
},
"command": {
"const": "check",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of checkbox element",
"type": "string"
}
},
"required": [
"command",
"selector"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
}
},
"type": "object"
},
"command": {
"const": "hover",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element to hover over",
"type": "string"
}
},
"required": [
"command",
"selector"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
}
},
"type": "object"
},
"command": {
"const": "focus",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element to focus",
"type": "string"
}
},
"required": [
"command",
"selector"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
}
},
"type": "object"
},
"command": {
"const": "blur",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element to blur",
"type": "string"
}
},
"required": [
"command",
"selector"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"key": {
"description": "Key to press (e.g., 'Enter', 'Tab', 'ArrowDown')",
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
},
"command": {
"const": "keypress",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element to target (optional)",
"type": "string"
}
},
"required": [
"command",
"args"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"x": {
"description": "Horizontal scroll amount in pixels (default: 0)",
"type": "number"
},
"y": {
"description": "Vertical scroll amount in pixels (default: 0)",
"type": "number"
}
},
"type": "object"
},
"command": {
"const": "scroll",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element to scroll (scrolls page if not provided)",
"type": "string"
}
},
"required": [
"command"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"name": {
"description": "Name of the attribute to retrieve",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"command": {
"const": "getAttribute",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element",
"type": "string"
}
},
"required": [
"command",
"selector",
"args"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"name": {
"description": "Name of the property to retrieve",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"command": {
"const": "getProperty",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
},
"selector": {
"description": "CSS selector of element",
"type": "string"
}
},
"required": [
"command",
"selector",
"args"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"continueOnError": {
"description": "Whether to continue executing commands if this command fails",
"type": "boolean"
},
"waitUntil": {
"description": "Navigation wait condition (default: networkidle0)",
"enum": [
"load",
"domcontentloaded",
"networkidle0",
"networkidle2"
],
"type": "string"
}
},
"type": "object"
},
"command": {
"const": "refresh",
"type": "string"
},
"description": {
"description": "Description of this command step",
"type": "string"
}
},
"required": [
"command"
],
"type": "object"
}
]
},
"type": "array"
},
"timeout": {
"description": "Overall timeout in milliseconds (default: 30000)",
"type": "number"
}
},
"required": [
"commands"
],
"type": "object"
}