Playwright.Touchscreen (Playwright v1.65.0-rc.3)

Copy Markdown View Source

The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the touchscreen can only be used in browser contexts that have been initialized with :has_touch set to true.

This class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching touch events, see the emulating legacy touch events page.

Since Playwright 1.8.

The examples alias the modules they use (alias Playwright.{Locator, Page}).

Summary

Types

t()

A Touchscreen handle. Compare handles with ==, their fields are internal.

Functions

Dispatches a touchstart and touchend event with a single touch at the position (x,y).

Like tap/3, but returns the value and raises on error.

Types

t()

@type t() :: %Playwright.Touchscreen{_page: term()}

A Touchscreen handle. Compare handles with ==, their fields are internal.

Functions

tap(touchscreen, x, y)

@spec tap(t(), number(), number()) :: :ok | {:error, Playwright.error()}

Dispatches a touchstart and touchend event with a single touch at the position (x,y).

Note

Playwright.Touchscreen.tap/3 will fail if the :has_touch option of the browser context is false.

Since Playwright 1.8.

Arguments

  • x - X coordinate relative to the main frame's viewport in CSS pixels.
  • y - Y coordinate relative to the main frame's viewport in CSS pixels.

tap!(touchscreen, x, y)

@spec tap!(t(), number(), number()) :: :ok

Like tap/3, but returns the value and raises on error.