What is Relative Mode?
By default, Playwright performs clicks at the center of an element. However, for canvas elements where the entire HTML element is a single<canvas>
tag, center-based clicking won’t provide the precision required.
Relative mode enables you to click at specific coordinates relative to an element’s boundaries, making it essential for accurate canvas interactions.
When to Use Relative Mode
Use relative mode when interacting with:- Canvas elements (
<canvas>
) - SVG elements
- Custom drawing applications
- Any element where precise positioning is critical
Enabling Relative Mode
To enable relative mode, click on the target icon in the control bar. This switches the click mode from center-based to coordinate-based interactions.

Two actions created in relative mode, drawing at specific coordinates on the canvas
Drag and drop actions automatically utilize relative mode for precise positioning.