The protocol is largely undocumented. Once connected, it follows the WebKit inspector protocol. The JSON protocol definitions live in the WebKit tree: Source/JavaScriptCore/inspector/protocol/.
Chrome DevTools protocol documentation is a useful reference: Chrome DevTools Protocol. Although the WebKit inspector protocol is similar to CDP, there are a couple of important differences that are not documented; they can only be found by reading the WebKit source code at github.com/WebKit/WebKit.
- Language / build: TypeScript; compile with
npm run build(watch:npm run dev). - Entry:
index.tsexportscreateRemoteDebugger(),RemoteDebugger,RemoteDebuggerRealDevice, andREMOTE_DEBUGGER_PORT. - Simulator vs real device: Use
RemoteDebugger(simulator) orRemoteDebuggerRealDevice(real device viaappium-ios-device). Both extend the same base; the real-device class wires inRpcClientRealDeviceinstead ofRpcClientSimulator. - RPC layer (
lib/rpc/):RpcClient(base),RpcClientSimulator,RpcClientRealDevice;RemoteMessagesbuilds Web Inspector commands;RpcMessageHandlerprocesses responses. - Protocol (
lib/protocol/): Maps Web Inspector domain/method names to parameter definitions used when building RPC commands. - Mixins (
lib/mixins/): Connect, execute, navigate, cookies, screenshot, events, message-handlers, misc, property-accessors. - Events:
RemoteDebugger.EVENT_PAGE_CHANGE,RemoteDebugger.EVENT_DISCONNECT,RemoteDebugger.EVENT_FRAMES_DETACHED(see README for usage). - Tests:
npm test(unit),npm run e2e-test(functional). Lint:npm run lint/npm run lint:fix. - Atoms: Selenium atoms live in
atoms/and are built withnpm run build:atoms. See README andatoms-notes.mdfor Selenium branch, bazel/bazelisk, and Appium-specific patches.
To inspect traffic between Safari’s Web Inspector and the simulator, use a Unix socket proxy with socat (on macOS: brew install socat):
- Get the simulator’s Web Inspector socket path (see below).
- Move the real socket aside and run socat so it listens where the socket was and forwards to the moved one:
# Move the real socket aside
sudo mv /path/to/unix-domain.socket /path/to/unix-domain.socket.original
# Proxy: listen on original path, connect to .original
sudo socat -t100 -x -v UNIX-LISTEN:/path/to/unix-domain.socket,mode=777,reuseaddr,fork UNIX-CONNECT:/path/to/unix-domain.socket.originalThen open Safari → Develop menu and attach to the simulator’s Web Inspector; the proxied traffic will appear in the terminal.
To get the socket path for a booted simulator, run:
npm run get-web-inspector-socket -- <simulator-udid>The script prints the actual socket path for the given Simulator UDID (it uses getWebInspectorSocket() from appium-ios-simulator)
A small utility runs the socat proxy for a given simulator UDID:
npm run inspect-safari -- <udid>Prerequisites: socat (e.g. brew install socat).
Steps:
- Run once: the script prints the simulator’s Web Inspector socket path, then starts socat. Socat expects the real socket to be at
<path>.original. - So before (or the first time you use this for a given simulator): move the real socket aside, e.g.
mv /path/to/com.apple.webinspectord_sim.socket /path/to/com.apple.webinspectord_sim.socket.original(use the path printed by the script; you may need to locate it vialsof -aUc launchd_simor similar if the script fails to connect). - Run
npm run inspect-safari -- <udid>again. It will start socat: it listens on the normal socket path and forwards to.original. Open Safari’s Web Inspector to the simulator; JSON-formatted communication will appear in the terminal.
Example (simulator):
# Get socket path for your booted simulator
npm run get-web-inspector-socket -- 8442C4CD-77B5-4764-A1F9-AABC7AD26209
# e.g. prints: /private/tmp/com.apple.launchd.xxx/com.apple.webinspectord_sim.socket
# Move real socket aside (use the path from above)
mv /private/tmp/.../com.apple.webinspectord_sim.socket /private/tmp/.../com.apple.webinspectord_sim.socket.original
# Start proxy and open Safari → Develop → simulator
npm run inspect-safari -- 8442C4CD-77B5-4764-A1F9-AABC7AD26209