Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Webdriverio Webdriverio WdioUtils Constants

From Leeroopedia
Knowledge Sources
Domains Constants, Protocol_Support
Last Updated 2026-02-12 00:00 GMT

Overview

Defines WebDriver unicode character mappings, supported browser name variants, default connection settings, and hook validation definitions used throughout the WebdriverIO utilities package.

Description

The WdioUtils Constants module exports several constant values central to WebdriverIO operations. UNICODE_CHARACTERS is a comprehensive mapping of key names (e.g., "Enter", "Tab", "ArrowLeft", "F1") to their W3C WebDriver unicode private-use-area code points, enabling keyboard input simulation. SUPPORTED_BROWSERNAMES maps canonical browser identifiers (chrome, firefox, edge, safari) to arrays of accepted name variants (e.g., chrome includes "googlechrome", "chromium", "chromium-browser"). DEFAULT_HOSTNAME, DEFAULT_PROTOCOL, and DEFAULT_PATH define the baseline connection parameters ("localhost", "http", "/") used to detect whether a user has configured a remote driver. HOOK_DEFINITION provides a type-validation object that ensures hook configuration values are arrays of functions, used by the config validation system.

Usage

Use UNICODE_CHARACTERS when sending special key sequences through the WebDriver protocol. Use SUPPORTED_BROWSERNAMES in browser detection logic to match user-provided browser names against known variants. Use the default connection constants when determining if custom remote connection settings have been configured. Use HOOK_DEFINITION in configuration schema validation to enforce that hooks are arrays of functions.

Code Reference

Source Location

Signature

export const UNICODE_CHARACTERS: {
    'NULL': '\uE000';
    'Enter': '\uE007';
    'Tab': '\uE004';
    'Escape': '\uE00C';
    'ArrowLeft': '\uE012';
    'ArrowUp': '\uE013';
    'ArrowRight': '\uE014';
    'ArrowDown': '\uE015';
    'Meta': '\uE03D';
    // ... 60+ key mappings total
} as const

export const SUPPORTED_BROWSERNAMES: {
    chrome: string[];
    firefox: string[];
    edge: string[];
    safari: string[];
}

export const DEFAULT_HOSTNAME: 'localhost'
export const DEFAULT_PROTOCOL: 'http'
export const DEFAULT_PATH: '/'

export const HOOK_DEFINITION: {
    type: 'object';
    validate: (param: unknown) => void;
}

Import

import { UNICODE_CHARACTERS, SUPPORTED_BROWSERNAMES } from '@wdio/utils'

I/O Contract

Inputs

Name Type Required Description
param unknown Yes (HOOK_DEFINITION.validate) The configuration value to validate as an array of functions.

Outputs

Name Type Description
UNICODE_CHARACTERS Record<string, string> Read-only mapping of 60+ key names to W3C WebDriver unicode code points.
SUPPORTED_BROWSERNAMES Record<string, string[]> Map of browser families to accepted name variants: chrome (4 variants), firefox (4), edge (3), safari (2).
DEFAULT_HOSTNAME string Default WebDriver hostname: "localhost".
DEFAULT_PROTOCOL string Default WebDriver protocol: "http".
DEFAULT_PATH string Default WebDriver path: "/".
HOOK_DEFINITION object Config validation object with type "object" and a validate function that throws if the value is not an array of functions.

Usage Examples

import { UNICODE_CHARACTERS, SUPPORTED_BROWSERNAMES, DEFAULT_HOSTNAME } from '@wdio/utils'

// Send an Enter key press via WebDriver protocol
const enterKey = UNICODE_CHARACTERS['Enter']  // '\uE007'
await browser.keys([enterKey])

// Check if a browser name is a known Chrome variant
const browserName = 'googlechrome'
const isKnownChrome = SUPPORTED_BROWSERNAMES.chrome.includes(browserName.toLowerCase())
console.log(isKnownChrome)  // true

// Check all supported Firefox names
console.log(SUPPORTED_BROWSERNAMES.firefox)
// ['firefox', 'ff', 'mozilla', 'mozilla firefox']

// Use default connection settings
console.log(DEFAULT_HOSTNAME)  // 'localhost'

// Use special keys by readable name
const keys = [
    UNICODE_CHARACTERS['Control'],
    'a'  // Select all
]
await browser.keys(keys)

Related Pages

Page Connections

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