Implementation:Webdriverio Webdriverio Appium Cli
| Knowledge Sources | |
|---|---|
| Domains | Mobile_Testing, CLI |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
The Appium CLI module is the entry point that starts an Appium server with the Inspector plugin and opens the Inspector in the default browser.
Description
The run function orchestrates the complete Appium Inspector launch sequence. It parses CLI arguments, extracts and normalizes the port, ensures required flags (--log-timestamp, --use-plugins=inspector, --allow-cors) are present, resolves the Appium command path, verifies the Inspector plugin is installed, starts the Appium server, and opens the Inspector URL in the default browser. It also registers SIGINT and SIGTERM handlers for graceful shutdown using tree-kill to terminate the entire process tree.
Usage
This module is invoked as a CLI command, typically via npx wdio-appium or as a binary entry point defined in the package's bin field.
Code Reference
Source Location
- Repository: Webdriverio_Webdriverio
- File: packages/wdio-appium-service/src/cli.ts
- Lines: 14-69
Signature
export async function run(): Promise<void>
Import
import { run } from './cli.js'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| process.argv | string[] |
Yes | Command line arguments passed to the process; arguments after the first two are used as Appium server arguments |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Promise<void> |
Resolves after the Appium server is started and the Inspector browser window is opened; the process remains running until SIGINT or SIGTERM is received |
Usage Examples
Running from the Command Line
// From terminal:
// npx wdio-appium --port 4723
//
// This triggers the run() function which:
// 1. Extracts port 4723 from args
// 2. Adds required flags: --log-timestamp, --use-plugins=inspector, --allow-cors
// 3. Resolves the appium command path
// 4. Checks that the inspector plugin is installed
// 5. Starts: node /path/to/appium server --port=4723 --log-timestamp --use-plugins=inspector --allow-cors
// 6. Opens http://localhost:4723/inspector in default browser
Graceful Shutdown
// When Ctrl+C is pressed:
// 1. cleanup() is called via SIGINT handler
// 2. tree-kill sends SIGTERM to appium process and all children
// 3. Signal handlers are removed to prevent duplicate calls
// 4. process.exit(0) is called