microsoft/playwright · error · Error

No mapping for ${text[i]} found

Error message

No mapping for ${text[i]} found

What it means

Thrown by AndroidDeviceDispatcher.inputType() when a character in the requested text has no entry in the static keyMap (androidDispatcher.ts:224). inputType translates each character to an Android keycode one-by-one via keyMap.get(text[i].toUpperCase()); any character not present in the map aborts the whole call before any key is sent. The map covers A-Z, 0-9, a fixed set of symbols (* # , . - = ( ) \ ; ` / @ and Tab/Space) and named keys — most punctuation, currency symbols, accented characters, and emoji are absent.

Source

Thrown at packages/playwright-core/src/server/dispatchers/androidDispatcher.ts:119

  }

  async swipe(params: channels.AndroidDeviceSwipeParams, progress: Progress) {
    await this._object.send(progress, 'swipe', params);
  }

  async info(params: channels.AndroidDeviceInfoParams, progress: Progress): Promise<channels.AndroidDeviceInfoResult> {
    const info = await this._object.send(progress, 'info', params);
    fixupAndroidElementInfo(info);
    return { info };
  }

  async inputType(params: channels.AndroidDeviceInputTypeParams, progress: Progress) {
    const text = params.text;
    const keyCodes: number[] = [];
    for (let i = 0; i < text.length; ++i) {
      const code = keyMap.get(text[i].toUpperCase());
      if (code === undefined)
        throw new Error('No mapping for ' + text[i] + ' found');
      keyCodes.push(code);
    }
    await progress.race(Promise.all(keyCodes.map(keyCode => this._object.send(progress, 'inputPress', { keyCode }))));
  }

  async inputPress(params: channels.AndroidDeviceInputPressParams, progress: Progress) {
    if (!keyMap.has(params.key))
      throw new Error('Unknown key: ' + params.key);
    await this._object.send(progress, 'inputPress', { keyCode: keyMap.get(params.key) });
  }

  async inputTap(params: channels.AndroidDeviceInputTapParams, progress: Progress) {
    await this._object.send(progress, 'inputClick', params);
  }

  async inputSwipe(params: channels.AndroidDeviceInputSwipeParams, progress: Progress) {
    await this._object.send(progress, 'inputSwipe', params);
  }

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Filter or replace unsupported characters before calling type(); restrict input to the characters present in keyMap (A-Z, 0-9, space, tab, and the listed punctuation).
  2. For arbitrary/Unicode text, set the field value directly via the element's setText / fill-style API or Android IME rather than keycode-by-keycode typing.
  3. Pre-validate input against the supported set and fail fast in your test with a clear message rather than hitting the server-side throw.

Example fix

// before: arbitrary text crashes on unsupported chars
await device.type(element, 'côte-d'ivoire $5.00');

// after: set the field value directly for non-mapped text
await device.fill(element, 'côte-d'ivoire $5.00');
// or sanitize to the mapped subset before typing
const safe = text.split('').filter(ch => androidKeyMap.has(ch.toUpperCase())).join('');
await device.type(element, safe);
Defensive patterns

Strategy: validation

Validate before calling

// Validate input against the Android keyMap before typing.
const SUPPORTED = new Set('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*#,-=()\\\\;`/@ \t'.split(''));
function isTypeableAndroid(text: string): boolean {
  for (const ch of text) if (!SUPPORTED.has(ch.toUpperCase())) return false;
  return true;
}
if (!isTypeableAndroid(text)) throw new Error(`Unsupported chars for Android type()`);

Type guard

function isAndroidTypeable(text: string): text is string {
  const supported = new Set('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*#,-=()\\\\;`/@ \t');
  return [...text].every(ch => supported.has(ch.toUpperCase()));
}

Try / catch

try {
  await device.fill(element, text);
} catch (e) {
  if (/No mapping for/.test(e.message)) {
    // fall back to setting the field value directly via setText
  } else throw e;
}

Prevention

When it happens

Trigger: Calling androidDevice.type(text) / the inputType RPC with text containing unsupported characters: '!', '$', '%', '^', '&', '_', '+', '[', ']', '{', '}', '|', ':', '"', '<', '>', '?', uppercase accented letters, CJK, or emoji. toUpperCase() does not help because these chars have no mapping at any case.

Common situations: Typing passwords, emails with '+', prices with '$'/'%', code snippets with braces/brackets, or any non-ASCII content into an Android field via type(); data-driven tests that pass arbitrary user input straight to type().

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/8a0b6c2476fe871a. Report an issue: GitHub.