pub struct Touchscreen { /* private fields */ }Expand description
Touchscreen controller for touch input simulation.
Provides methods for tapping and touch gestures.
Requires touch to be enabled via enable or hasTouch: true
in browser context options.
§Example
// Enable touch on the page
page.touchscreen().enable().await.unwrap();
// Tap at coordinates
page.touchscreen().tap(100.0, 200.0).await.unwrap();Implementations§
Source§impl Touchscreen
impl Touchscreen
Sourcepub async fn enable(&self) -> Result<(), LocatorError>
pub async fn enable(&self) -> Result<(), LocatorError>
Enable touch emulation.
This must be called before using touch methods, or touch must be enabled in browser context options.
§Arguments
max_touch_points- Maximum number of touch points. Defaults to 1.
§Example
use viewpoint_core::page::Page;
// Enable touch with default settings
page.touchscreen().enable().await?;
// Enable touch with multiple touch points
page.touchscreen().enable_with_max_points(5).await?;Sourcepub async fn enable_with_max_points(
&self,
max_touch_points: i32,
) -> Result<(), LocatorError>
pub async fn enable_with_max_points( &self, max_touch_points: i32, ) -> Result<(), LocatorError>
Enable touch emulation with a specific maximum number of touch points.
Sourcepub async fn disable(&self) -> Result<(), LocatorError>
pub async fn disable(&self) -> Result<(), LocatorError>
Disable touch emulation.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if touch emulation is enabled.
Sourcepub async fn tap(&self, x: f64, y: f64) -> Result<(), LocatorError>
pub async fn tap(&self, x: f64, y: f64) -> Result<(), LocatorError>
Tap at the specified coordinates.
Dispatches touchStart and touchEnd events.
§Arguments
x- X coordinate in CSS pixelsy- Y coordinate in CSS pixels
§Errors
Returns LocatorError::TouchNotEnabled if touch emulation is not enabled.
Call enable first or set hasTouch: true in context options.
§Example
use viewpoint_core::page::Page;
page.touchscreen().enable().await?;
page.touchscreen().tap(100.0, 200.0).await?;Sourcepub async fn tap_with_modifiers(
&self,
x: f64,
y: f64,
modifiers: i32,
) -> Result<(), LocatorError>
pub async fn tap_with_modifiers( &self, x: f64, y: f64, modifiers: i32, ) -> Result<(), LocatorError>
Tap with modifiers (Shift, Control, etc).
§Errors
Returns LocatorError::TouchNotEnabled if touch emulation is not enabled.