--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
Example Usage
Assert Pin Value (expect-pin)
Check if a pin is set to an expected value.
Parameters
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
Example Usage
Wait and Match Text from Serial (wait-serial)
Wait for serial console output which matches a given string.
Parameters
Example Usage
Write to Serial (write-serial)
Write text or an array of numbers to the serial console.
Parameters
Example Usage
- String
- Array
Take a Screenshot (take-screenshot)
Take a screenshot of a specific component and compare it with an existing capture.
Parameters
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
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
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
Example Usage
Touch Release (touch-release)
Low-level touch command: release the touch.
Parameters
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.
1
Clone the Repository
Begin with cloning the repository:
2
Navigate to the Test
Navigate to the part in question:
3
Build the Firmware
Build the required microcontroller firmware:
This can also be done via the PlatformIO VS Code extension - just click the build button.
4
Run the Test
Finally, run the test:
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