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.

Workflow:Getgauge Taiko Interactive Test Recording

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Test_Recording, REPL
Last Updated 2026-02-12 03:00 GMT

Overview

End-to-end process for interactively recording browser automation scripts using Taiko's REPL, then generating and executing the resulting test code.

Description

This workflow covers the primary "record and playback" use case of Taiko. The user launches Taiko's interactive REPL, which opens a browser instance. The user types Taiko API commands (goto, click, write, etc.) one at a time, observing each action execute in real time. The REPL maintains a history of all successful commands. When the user is satisfied with the flow, the REPL generates a clean, maintainable JavaScript test script that can be saved to a file and replayed. The generated script wraps all commands in an async IIFE with proper error handling and browser cleanup.

Usage

Execute this workflow when you need to quickly prototype a browser automation script by exploring a web application interactively. This is the recommended starting point for new Taiko users and for scripting unfamiliar web pages where you want to discover the right selectors and actions through trial and error rather than inspecting source code.

Execution Steps

Step 1: Launch the REPL

Start the Taiko interactive recorder by invoking the CLI without a script argument. This initializes the REPL environment, loads all Taiko API functions into the global scope, and presents a command prompt. Optional flags can enable device emulation or network throttling from the start.

Key considerations:

  • The REPL automatically provides all Taiko APIs as global commands
  • Use the `.api` command to explore available APIs and see documentation
  • Optional `--emulate-device` and `--emulate-network` flags configure emulation at launch

Step 2: Open a Browser Instance

Call the browser launch command from the REPL prompt. When invoked from the REPL, the browser opens in headful (visible) mode by default so the user can observe actions. This step establishes the CDP (Chrome DevTools Protocol) WebSocket connection that all subsequent commands use.

Key considerations:

  • The REPL launches in headful mode by default (unlike script mode which defaults to headless)
  • Custom Chrome arguments can be passed for specific configurations
  • The browser process lifecycle is tied to the REPL session

Step 3: Navigate and Interact

Type Taiko API commands one by one at the REPL prompt. Each command executes immediately against the live browser, and the user sees the result in real time. Commands include navigation (goto), text input (write), clicking (click), and assertions (text().exists()). Taiko's smart selectors find elements by visible text without requiring CSS or XPath selectors, and implicit waits handle dynamic content automatically.

Key considerations:

  • Each command runs immediately and the browser reflects the action visually
  • Failed commands are not recorded in the history
  • The REPL supports standard Node.js code in addition to Taiko APIs
  • Proximity selectors (near, above, below, toLeftOf, toRightOf) help locate elements spatially

Step 4: Generate Test Script

Use the `.code` REPL command to generate a JavaScript file from the recorded command history. The generator produces a clean async IIFE that imports only the Taiko APIs actually used, wraps actions in try/catch/finally for error handling, and ensures browser cleanup. The script can be saved to a file by passing a filename argument to `.code`.

Key considerations:

  • Only successful commands are included in the generated code
  • The generated script includes proper require/import statements for used APIs
  • Use `.code filename.js` to save directly to a file
  • The `.step` command generates Gauge step definitions instead of plain scripts

Step 5: Run the Generated Script

Execute the saved test script using the Taiko CLI runner. By default, the script runs in headless mode for fast, CI-friendly execution. The `--observe` flag can be used to run in headful mode with action delays for debugging. The runner logs each action's success or failure to the console.

Key considerations:

  • Headless mode is the default for script execution (no visible browser)
  • Use `--observe` flag to see browser actions with a 3-second delay between steps
  • Scripts can also be run via `node` directly, but Taiko's runner provides action logging
  • The `--load` flag combined with the `repl()` API allows resuming a REPL session mid-script

Execution Diagram

GitHub URL

Workflow Repository