Labsco
Winify logo

WebDriverIO

β˜… 20

from Winify

Automate web browsers using WebDriverIO. Supports actions like clicking, filling forms, and taking screenshots.

πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

WebDriverIO MCP Server

⚠️ Project Archived

This project is no longer under active development. The official WebDriverIO MCP server is now available as @wdio/mcp, which was built using this project as its foundation.

πŸ‘‰ Use the official package instead: https://github.com/webdriverio/mcp

A Model Context Protocol (MCP) server that enables Claude Desktop to interact with web browsers and mobile applications using WebDriverIO. Automate Chrome browsers, iOS apps, and Android appsβ€”all through a unified interface.

Features

Browser Automation

  • Session Management: Start and close Chrome browser sessions with headless/headed modes
  • Navigation & Interaction: Navigate URLs, click elements, fill forms, and retrieve content
  • Page Analysis: Get visible elements, accessibility trees, take screenshots
  • Cookie Management: Get, set, and delete cookies
  • Scrolling: Smooth scrolling with configurable distances

Mobile App Automation (iOS/Android)

  • Native App Testing: Test iOS (.app/.ipa) and Android (.apk) apps via Appium
  • Touch Gestures: Tap, swipe, long-press, drag-and-drop
  • App Lifecycle: Launch, background, terminate, check app state
  • Context Switching: Seamlessly switch between native and webview contexts for hybrid apps
  • Device Control: Rotate, lock/unlock, geolocation, keyboard control, notifications
  • Cross-Platform Selectors: Accessibility IDs, XPath, UiAutomator (Android), Predicates (iOS)

Available Tools

Session Management

ToolDescription
start_browserStart a Chrome browser session (headless/headed, custom dimensions)
start_app_sessionStart an iOS or Android app session via Appium (supports state preservation via noReset)
close_sessionClose or detach from the current browser or app session (supports detach mode)

Navigation & Page Interaction (Web & Mobile)

ToolDescription
navigateNavigate to a URL
get_visible_elementsGet visible, interactable elements on the page. Supports inViewportOnly (default: true) to filter viewport elements, and includeContainers (default: false) to include layout containers on mobile
get_accessibilityGet accessibility tree with semantic element information
scroll_downScroll down by specified pixels
scroll_upScroll up by specified pixels
take_screenshotCapture a screenshot

Element Interaction (Web & Mobile)

ToolDescription
find_elementFind an element using CSS selectors, XPath, or mobile selectors
click_elementClick an element
click_via_textClick an element by text content
set_valueType text into input fields
get_element_textGet text content of an element
is_displayedCheck if an element is displayed

Cookie Management (Web)

ToolDescription
get_cookiesGet all cookies or a specific cookie by name
set_cookieSet a cookie with name, value, and optional attributes
delete_cookiesDelete all cookies or a specific cookie

Mobile Gestures (iOS/Android)

ToolDescription
tap_elementTap an element by selector or coordinates
swipeSwipe in a direction (up/down/left/right)
long_pressLong press an element or coordinates
drag_and_dropDrag from one location to another

App Lifecycle (iOS/Android)

ToolDescription
get_app_stateCheck app state (installed, running, background, foreground)
activate_appBring app to foreground
terminate_appTerminate a running app

Context Switching (Hybrid Apps)

ToolDescription
get_contextsList available contexts (NATIVE_APP, WEBVIEW_*)
get_current_contextShow the currently active context
switch_contextSwitch between native and webview contexts

Device Control (iOS/Android)

ToolDescription
get_device_infoGet device platform, version, screen size
rotate_deviceRotate to portrait or landscape orientation
get_orientationGet current device orientation
lock_device / unlock_deviceLock or unlock device screen
is_device_lockedCheck if device is locked
shake_deviceShake the device (iOS only)
send_keysSend keyboard input (Android only)
press_key_codePress Android key code (BACK=4, HOME=3, etc.)
hide_keyboard / is_keyboard_shownControl on-screen keyboard
open_notificationsOpen notifications panel (Android only)
get_geolocation / set_geolocationGet or set device GPS location

Important Notes

⚠️ Session Management:

  • Only one session (browser OR app) can be active at a time
  • Always close sessions when done to free system resources
  • To switch between browser and mobile, close the current session first
  • Use close_session({ detach: true }) to disconnect without terminating the session on the Appium server
  • State preservation can be controlled with noReset and fullReset parameters during session creation
  • Sessions created with noReset: true or without appPath will automatically detach on close

⚠️ Task Planning:

  • Break complex automation into smaller, focused operations
  • Claude may consume message limits quickly with extensive automation

⚠️ Mobile Automation:

  • Appium server must be running before starting mobile sessions
  • Ensure emulators/simulators are running and devices are connected
  • iOS automation requires macOS with Xcode installed
  • iOS Real Devices: Testing on physical iOS devices requires the device's UDID (40-character unique identifier). See Prerequisites section for how to find your UDID

Selector Syntax Quick Reference

Web (CSS/XPath):

  • CSS: button.my-class, #element-id
  • XPath: //button[@class='my-class']
  • Text: button=Exact text, a*=Contains text

Mobile (Cross-Platform):

  • Accessibility ID: ~loginButton (works on both iOS and Android)
  • Android UiAutomator: android=new UiSelector().text("Login")
  • iOS Predicate: -ios predicate string:label == "Login" AND visible == 1
  • XPath: //android.widget.Button[@text="Login"]

Advanced Features

App State Preservation

State Preservation with noReset/fullReset: Control app state when creating new sessions using the noReset and fullReset parameters:

noResetfullResetBehavior
truefalsePreserve state: App stays installed, data preserved
falsefalseClear app data but keep app installed (default)
falsetrueFull reset: Uninstall and reinstall app (clean slate)

Example with state preservation:

Copy & paste β€” that's it
// Preserve login state between test runs
start_app_session({
  platform: 'Android',
  appPath: '/path/to/app.apk',
  deviceName: 'emulator-5554',
  noReset: true,         // Don't reset app state
  fullReset: false,      // Don't uninstall
  autoGrantPermissions: true
})
// App launches with existing user data, login tokens, preferences intact

Detach from Sessions: The close_session tool supports a detach parameter that disconnects from the session without terminating it on the Appium server:

Copy & paste β€” that's it
// Detach without killing the session
close_session({ detach: true })

// Standard session termination (closes the app and removes session)
close_session({ detach: false })  // or just close_session()

Sessions created with noReset: true or without appPath will automatically detach on close.

This is particularly useful when:

  • Preserving app state for manual testing continuation
  • Debugging multi-step workflows (leave session running between tool invocations)
  • Testing scenarios where you want the app to remain installed and in current state

Smart Element Detection

  • Platform-specific element classification: Automatically identifies interactable elements vs layout containers
    • Android: Button, EditText, CheckBox vs ViewGroup, FrameLayout, ScrollView
    • iOS: Button, TextField, Switch vs View, StackView, CollectionView
  • Multiple locator strategies: Each element provides accessibility ID, resource ID, text, XPath, and platform-specific selectors
  • Viewport filtering: Control whether to get only visible elements or all elements including off-screen
  • Layout debugging: Optionally include container elements to understand UI hierarchy

Automatic Permission & Alert Handling

Both iOS and Android sessions now support automatic handling of system permissions and alerts:

  • autoGrantPermissions (default: true): Automatically grants app permissions (camera, location, etc.)
  • autoAcceptAlerts (default: true): Automatically accepts system alerts and dialogs
  • autoDismissAlerts (optional): Set to true to dismiss alerts instead of accepting them

This eliminates the need to manually handle permission popups during automated testing.

Technical Details

  • Built with: TypeScript, WebDriverIO, Appium
  • Browser Support: Chrome (headed/headless, automated driver management)
  • Mobile Support: iOS (XCUITest) and Android (UiAutomator2/Espresso)
  • Protocol: Model Context Protocol (MCP) for Claude Desktop integration
  • Session Model: Single active session (browser or mobile app)
  • Data Format: TOON (Token-Oriented Object Notation) for efficient LLM communication
  • Element Detection: XML-based page source parsing with intelligent filtering and multi-strategy locator generation