Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright AndroidDispatcher

From Leeroopedia
Revision as of 11:35, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_AndroidDispatcher.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains RPC Protocol, Mobile Testing
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for exposing Android automation over the RPC protocol provided by the Playwright library.

Description

The `AndroidDispatcher` and `AndroidDeviceDispatcher` classes bridge the server-side Android automation objects to the client via Playwright's RPC dispatcher system. `AndroidDispatcher` wraps the server `Android` object and handles device discovery requests. `AndroidDeviceDispatcher` wraps individual `AndroidDevice` instances and dispatches events (WebView added/removed, close) and methods (tap, swipe, drag, fling, pinch, screenshot, shell, open browser, input operations) to the client. It also includes `AndroidSocketDispatcher` for socket-based communication channels. Each dispatcher translates between channel protocol types and internal server types.

Usage

Use these dispatchers when the Playwright server needs to expose Android automation capabilities to remote clients over the RPC protocol. They are registered automatically when an Android connection is established.

Code Reference

Source Location

  • Repository: Microsoft_Playwright
  • File: packages/playwright-core/src/server/dispatchers/androidDispatcher.ts

Signature

export class AndroidDispatcher extends Dispatcher<Android, channels.AndroidChannel, RootDispatcher> implements channels.AndroidChannel {
  _type_Android: true;
  constructor(scope: RootDispatcher, android: Android);
  async devices(params: channels.AndroidDevicesParams, progress: Progress): Promise<channels.AndroidDevicesResult>;
}

export class AndroidDeviceDispatcher extends Dispatcher<AndroidDevice, channels.AndroidDeviceChannel, AndroidDispatcher> implements channels.AndroidDeviceChannel {
  _type_EventTarget: true;
  _type_AndroidDevice: true;
  static from(scope: AndroidDispatcher, device: AndroidDevice): AndroidDeviceDispatcher;
  constructor(scope: AndroidDispatcher, device: AndroidDevice);
}

Import

import { AndroidDispatcher, AndroidDeviceDispatcher } from '../server/dispatchers/androidDispatcher';

I/O Contract

Inputs

Name Type Required Description
scope RootDispatcher Yes Root dispatcher scope for object registration
android Android Yes Server-side Android manager object to wrap
device AndroidDevice Yes Server-side Android device object to wrap
params channels.AndroidDevicesParams Yes Device discovery parameters

Outputs

Name Type Description
devices AndroidDeviceDispatcher[] List of device dispatchers for discovered devices
events channel events WebView added/removed and close events dispatched to client

Usage Examples

// Created by the PlaywrightDispatcher when Android is available
const androidDispatcher = new AndroidDispatcher(rootScope, serverAndroid);

// Client calls devices() which is dispatched here
const result = await androidDispatcher.devices({ port: 5037 }, progress);
// result.devices contains AndroidDeviceDispatcher instances

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment