--scenario CLI option to load an automation scenario file.
Scenario File Structure
The basic structure of an automation scenario file is as follows:Available Steps
These can be used as a sequence of actions to perform when running the scenario. Use these to build a list of steps for testing your project.Wait (delay)
Wait for an amount of time.
Parameters
| Name | Description |
|---|---|
value | Amount of time to wait for. Units are required (e.g. 200ms) |
Example Usage
Assert Pin Value (expect-pin)
Check if a pin is set to an expected value.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target component |
pin | Name of pin to check |
value | Expected value of the pin |
Example Usage
Control a Part (set-control)
Set a controllable part of a component to a specified value. View part documentation for available controls or see a list of supported parts below.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target component |
control | Aspect of the target component to modify (e.g. temperature, humidity) |
value | Value to set the control to |
Example Usage
Wait and Match Text from Serial (wait-serial)
Wait for serial console output which matches a given string.
Parameters
| Name | Description |
|---|---|
text | String to wait and match for |
Example Usage
Write to Serial (write-serial)
Write text or an array of numbers to the serial console.
Parameters
| Name | Description |
|---|---|
value | The string or array of numbers to write to the serial console |
Example Usage
- String
- Array
Take a Screenshot (take-screenshot)
Take a screenshot of a specific component and compare it with an existing capture.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target component |
save-to | Path to save screenshot to |
compare-with | Path of a screenshot to compare with |
This step requires
part-id and save-to and/or compare-with.Example Usage
Touch a Part (touch)
Simulate a touch tap on a part with a touchscreen. Sends a press event at the given coordinates, and automatically releases after duration.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target part (e.g. the board with a touchscreen) |
x | X coordinate (touch controller coordinates) |
y | Y coordinate (touch controller coordinates) |
duration | How long to hold the touch (optional, default: 50ms) |
wait | If true, wait for the touch duration before continuing (optional, default: false) |
Example Usage
Touch Press (touch-press)
Low-level touch command: send a press event at the given coordinates. Pair with touch-release to complete the gesture.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target part |
x | X coordinate (touch controller coordinates) |
y | Y coordinate (touch controller coordinates) |
Example Usage
Touch Move (touch-move)
Low-level touch command: send a move (drag) event to new coordinates. Use between touch-press and touch-release.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target part |
x | X coordinate (touch controller coordinates) |
y | Y coordinate (touch controller coordinates) |
Example Usage
Touch Release (touch-release)
Low-level touch command: release the touch.
Parameters
| Name | Description |
|---|---|
part-id | ID of the target part |
Example Usage
Touch Coordinate SystemTouch coordinates use the touch controller’s coordinate space, matching real hardware behavior. For most display+touch combinations (e.g. ILI9341 with FT6206), the touch controller’s origin (0, 0) is at the bottom-right of the display, not the top-left.Your firmware is responsible for mapping touch coordinates to display coordinates, just like on real hardware. For example, with the Adafruit FT6206 library on a 240x320 ILI9341 display:
Drag Gesture Example
Combine the low-level touch commands to simulate a drag gesture:Running Scenarios
To build the test projects and run the tests, you need to install PlatformIO Core and the Wokwi CLI, get a Wokwi CI token and set theWOKWI_CLI_TOKEN environment variable with the token.
You can then use pio run to compile the project and wokwi-cli . --scenario <scenario_file>.yaml to run the tests. You can also use Wokwi for VS Code to interactively simulate the test projects.
Example Usage
Example parts with test scenarios are available at the wokwi-part-tests GitHub repository. We will try to compile and run tests for thewokwi-dht22 part on the ESP32.
Build the Firmware
Build the required microcontroller firmware:
This can also be done via the PlatformIO VS Code extension - just click the build button.
Supported Parts with Automation Controls
Several Wokwi parts support automation controls that can be controlled using automation scenarios. These controls allow you to programmatically change the state of sensors, press buttons, and modify component values during simulation.Parts with Automation Controls
Push Button
Control button presses and releases
Potentiometer
Adjust the potentiometer position
MPU6050 Sensor
Set acceleration, rotation, and temperature values
Analog Joystick
Set direction and pressed state
HX711 Load Cell
Set load value of scale
Photoresistor Sensor
Set lux value