Skip to main content

Tools

The following tools are available through the WebdriverIO MCP server. These tools enable AI assistants to automate browsers and mobile applications.

Session Managementโ€‹

start_browserโ€‹

Launches a Chrome browser session.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
headlessbooleanNofalseRun Chrome in headless mode
windowWidthnumberNo1920Browser window width (400-3840)
windowHeightnumberNo1080Browser window height (400-2160)
navigationUrlstringNo-URL to navigate to after starting the browser

Exampleโ€‹

Start a browser with 1920x1080 resolution and navigate to webdriver.io

Supportโ€‹

  • Desktop Browsers

start_app_sessionโ€‹

Launches a mobile app session on iOS or Android via Appium.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
platformstringYes-Platform to automate: iOS or Android
deviceNamestringYes-Name of the device or simulator/emulator
appPathstringNo*-Path to the app file (.app, .ipa, or .apk)
platformVersionstringNo-OS version (e.g., 17.0, 14)
automationNamestringNoAutoXCUITest (iOS), UiAutomator2 or Espresso (Android)
udidstringNo-Unique device identifier (required for real iOS devices)
noResetbooleanNofalsePreserve app state between sessions
fullResetbooleanNotrueUninstall and reinstall app before session
autoGrantPermissionsbooleanNotrueAutomatically grant app permissions
autoAcceptAlertsbooleanNotrueAutomatically accept system alerts
autoDismissAlertsbooleanNofalseDismiss (instead of accept) alerts
appWaitActivitystringNo-Activity to wait for on launch (Android only)
newCommandTimeoutnumberNo60Seconds before session times out due to inactivity
appiumHoststringNo127.0.0.1Appium server hostname
appiumPortnumberNo4723Appium server port
appiumPathstringNo/Appium server path

*Either appPath must be provided, or noReset: true to connect to an already-running app.

Exampleโ€‹

Start an iOS app session on iPhone 15 simulator with my app at /path/to/app.app

Supportโ€‹

  • iOS Simulators
  • iOS Real Devices
  • Android Emulators
  • Android Real Devices

close_sessionโ€‹

Closes the current browser or app session.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
detachbooleanNofalseDetach from session instead of closing (keeps browser/app running)

Notesโ€‹

Sessions with noReset: true or without appPath automatically detach on close to preserve state.

Supportโ€‹

  • Desktop Browsers
  • Mobile Apps

Navigates to a URL.

Parametersโ€‹

ParameterTypeMandatoryDescription
urlstringYesThe URL to navigate to

Exampleโ€‹

Navigate to https://webdriver.io

Supportโ€‹

  • Desktop Browsers

Element Interactionโ€‹

click_elementโ€‹

Clicks an element identified by a selector.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
selectorstringYes-CSS selector, XPath, or mobile selector
scrollToViewbooleanNotrueScroll element into view before clicking
timeoutnumberNo3000Max time to wait for element (ms)

Notesโ€‹

  • Supports WebdriverIO text selectors: button=Exact text or a*=Contains text
  • Uses center alignment for scroll positioning

Exampleโ€‹

Click the element with selector "#submit-button"

Supportโ€‹

  • Desktop Browsers
  • Mobile Native Apps

set_valueโ€‹

Types text into an input field.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
selectorstringYes-Selector for the input element
valuestringYes-Text to type
scrollToViewbooleanNotrueScroll element into view before typing
timeoutnumberNo3000Max time to wait for element (ms)

Notesโ€‹

Clears existing value before typing new text.

Exampleโ€‹

Set the value "john@example.com" in the element with selector "#email"

Supportโ€‹

  • Desktop Browsers
  • Mobile Native Apps

Page Analysisโ€‹

get_visible_elementsโ€‹

Gets visible and interactable elements on the current page or screen. This is the primary tool for discovering what elements are available for interaction.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
elementTypestringNointeractableType of elements: interactable (buttons/links/inputs), visual (images/SVGs), or all
inViewportOnlybooleanNotrueOnly return elements visible in the viewport
includeContainersbooleanNofalseInclude layout containers (ViewGroup, ScrollView, etc.)
includeBoundsbooleanNofalseInclude element coordinates (x, y, width, height)
limitnumberNo0Maximum elements to return (0 = unlimited)
offsetnumberNo0Number of elements to skip (for pagination)

Returnsโ€‹

{
"total": 42,
"showing": 20,
"hasMore": true,
"elements": [...]
}

Web elements include: tagName, type, id, className, textContent, value, placeholder, href, ariaLabel, role, cssSelector, isInViewport

Mobile elements include: Multiple locator strategies (accessibility ID, resource ID, XPath, UiAutomator/predicates), element type, text, and optionally bounds

Notesโ€‹

  • Web: Uses an optimized browser script for fast element detection
  • Mobile: Uses efficient XML page source parsing (2 HTTP calls vs 600+ for element queries)
  • Use pagination (limit and offset) for large pages to reduce token usage

Exampleโ€‹

Get all visible elements on the page with their coordinates

Supportโ€‹

  • Desktop Browsers
  • Mobile Apps

get_accessibilityโ€‹

Gets the accessibility tree of the current page with semantic information about roles, names, and states.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
limitnumberNo100Maximum nodes to return (0 = unlimited)
offsetnumberNo0Number of nodes to skip (for pagination)
rolesstring[]NoAllFilter to specific roles (e.g., ["button", "link", "textbox"])
namedOnlybooleanNotrueOnly return nodes with a name/label

Returnsโ€‹

{
"total": 85,
"showing": 100,
"hasMore": false,
"nodes": [
{ "role": "button", "name": "Submit" },
{ "role": "link", "name": "Home" }
]
}

Notesโ€‹

  • Browser-only. For mobile apps, use get_visible_elements instead
  • Useful when get_visible_elements doesn't return expected elements
  • namedOnly: true filters out anonymous containers and reduces noise

Supportโ€‹

  • Desktop Browsers

Screenshotsโ€‹

take_screenshotโ€‹

Captures a screenshot of the current viewport.

Parametersโ€‹

ParameterTypeMandatoryDescription
outputPathstringNoPath to save screenshot file. If omitted, returns base64 data

Returnsโ€‹

Base64-encoded image data (PNG or JPEG) with size information.

Notesโ€‹

Screenshots are automatically optimized:

  • Maximum dimension: 2000px (scaled down if larger)
  • Maximum file size: 1MB
  • Format: PNG with max compression, or JPEG if needed to meet size limit

Supportโ€‹

  • Desktop Browsers
  • Mobile Apps

Scrollingโ€‹

scrollโ€‹

Scrolls the page up or down by a specified number of pixels.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
directionstringYes-Scroll direction: up or down
pixelsnumberNo500Number of pixels to scroll

Notesโ€‹

Browser-only. For mobile scrolling, use the swipe tool instead.

Supportโ€‹

  • Desktop Browsers

get_cookiesโ€‹

Gets cookies from the current session.

Parametersโ€‹

ParameterTypeMandatoryDescription
namestringNoSpecific cookie name to retrieve (omit for all cookies)

Returnsโ€‹

Cookie objects with name, value, domain, path, expiry, secure, and httpOnly properties.

Supportโ€‹

  • Desktop Browsers

Sets a cookie in the current session.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
namestringYes-Cookie name
valuestringYes-Cookie value
domainstringNoCurrentCookie domain
pathstringNo/Cookie path
expirynumberNo-Expiration as Unix timestamp (seconds)
securebooleanNo-Secure flag
httpOnlybooleanNo-HttpOnly flag
sameSitestringNo-SameSite attribute: strict, lax, or none

Supportโ€‹

  • Desktop Browsers

delete_cookiesโ€‹

Deletes cookies from the current session.

Parametersโ€‹

ParameterTypeMandatoryDescription
namestringNoSpecific cookie name to delete (omit to delete all)

Supportโ€‹

  • Desktop Browsers

Touch Gestures (Mobile)โ€‹

tap_elementโ€‹

Taps on an element or screen coordinates.

Parametersโ€‹

ParameterTypeMandatoryDescription
selectorstringNo*Selector for the element to tap
xnumberNo*X coordinate for tap
ynumberNo*Y coordinate for tap

*Either selector or both x and y are required.

Supportโ€‹

  • Mobile Apps

swipeโ€‹

Performs a swipe gesture in the specified direction.

Parametersโ€‹

ParameterTypeMandatoryDefaultDescription
directionstringYes-Swipe direction: up, down, left, right
durationnumberNo500Swipe duration in milliseconds (100-5000)
percentnumberNo0.5/0.95Percentage of screen to swipe (0-1)

Notesโ€‹

  • Default percent: 0.5 for vertical swipes, 0.95 for horizontal swipes
  • Direction indicates content movement: "swipe up" scrolls content up

Exampleโ€‹

Swipe up to scroll down the screen

Supportโ€‹

  • Mobile Apps

drag_and_dropโ€‹

Drags an element to another element or coordinates.

Parametersโ€‹

ParameterTypeMandatoryDescription
sourceSelectorstringYesSource element selector to drag
targetSelectorstringNo*Target element selector to drop onto
xnumberNo*Target X offset (if no targetSelector)
ynumberNo*Target Y offset (if no targetSelector)
durationnumberNoDefault

*Either targetSelector or both x and y are required.

Supportโ€‹

  • Mobile Apps

App Lifecycle (Mobile)โ€‹

get_app_stateโ€‹

Gets the current state of an app.

Parametersโ€‹

ParameterTypeMandatoryDescription
bundleIdstringYesApp identifier (bundle ID for iOS, package name for Android)

Returnsโ€‹

App state: not installed, not running, running in background (suspended), running in background, or running in foreground.

Supportโ€‹

  • Mobile Apps

Context Switching (Hybrid Apps)โ€‹

get_contextsโ€‹

Lists all available contexts (native and webviews).

Parametersโ€‹

None

Returnsโ€‹

Array of context names (e.g., ["NATIVE_APP", "WEBVIEW_com.example.app"]).

Supportโ€‹

  • Mobile Hybrid Apps

get_current_contextโ€‹

Gets the currently active context.

Parametersโ€‹

None

Returnsโ€‹

Current context name (e.g., NATIVE_APP or WEBVIEW_*).

Supportโ€‹

  • Mobile Hybrid Apps

switch_contextโ€‹

Switches between native and webview contexts.

Parametersโ€‹

ParameterTypeMandatoryDescription
contextstringYesContext name or index (1-based) from get_contexts

Exampleโ€‹

Switch to the WEBVIEW_com.example.app context

Supportโ€‹

  • Mobile Hybrid Apps

Device Control (Mobile)โ€‹

rotate_deviceโ€‹

Rotates the device to a specific orientation.

Parametersโ€‹

ParameterTypeMandatoryDescription
orientationstringYesPORTRAIT or LANDSCAPE

Supportโ€‹

  • Mobile Apps

hide_keyboardโ€‹

Hides the on-screen keyboard.

Parametersโ€‹

None

Supportโ€‹

  • Mobile Apps

get_geolocationโ€‹

Gets the current GPS coordinates.

Parametersโ€‹

None

Returnsโ€‹

Object with latitude, longitude, and altitude.

Supportโ€‹

  • Mobile Apps

set_geolocationโ€‹

Sets the device GPS coordinates.

Parametersโ€‹

ParameterTypeMandatoryDescription
latitudenumberYesLatitude coordinate (-90 to 90)
longitudenumberYesLongitude coordinate (-180 to 180)
altitudenumberNoAltitude in meters

Exampleโ€‹

Set geolocation to San Francisco (37.7749, -122.4194)

Supportโ€‹

  • Mobile Apps

Script Executionโ€‹

execute_scriptโ€‹

Executes JavaScript in the browser or mobile commands via Appium.

Parametersโ€‹

ParameterTypeMandatoryDescription
scriptstringYesJavaScript code (browser) or mobile command (e.g., mobile: pressKey)
argsarrayNoArguments for the script

Browser Examplesโ€‹

// Get page title
execute_script({ script: "return document.title" })

// Get scroll position
execute_script({ script: "return window.scrollY" })

// Click element by selector
execute_script({ script: "arguments[0].click()", args: ["#myButton"] })

Mobile (Appium) Examplesโ€‹

// Press back key (Android)
execute_script({ script: "mobile: pressKey", args: [{ keycode: 4 }] })

// Activate app
execute_script({ script: "mobile: activateApp", args: [{ appId: "com.example" }] })

// Terminate app
execute_script({ script: "mobile: terminateApp", args: [{ appId: "com.example" }] })

// Deep link
execute_script({ script: "mobile: deepLink", args: [{ url: "myapp://screen", package: "com.example" }] })

// Shell command (Android)
execute_script({ script: "mobile: shell", args: [{ command: "dumpsys", args: ["battery"] }] })

Common Android Key Codesโ€‹

KeyCode
BACK4
HOME3
ENTER66
MENU82
SEARCH84

More Mobile Commandsโ€‹

For a complete list of available Appium mobile commands, see:

Supportโ€‹

  • Desktop Browsers
  • Mobile Apps (via Appium mobile commands)

Welcome! How can I help?

WebdriverIO AI Copilot