microsoft / microsoft/playwright

[Feature]: Add Touch Drag and Touch Primitive Actions

Open
#39,043 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3-collecting-feedback
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

🚀 Feature Request

Add native touch drag support and low-level touch primitives to Playwright's API to enable comprehensive mobile touch interaction and browser touch interaction testing with the hasTouch flag enabled.

Use Cases

  • Testing drag-and-drop functionality on mobile web applications
  • Validating swipe gestures (carousels, image galleries, swipe-to-delete)
  • Testing touch-based UI controls (sliders, range selectors, draw/sketch features)
  • Simulating complex multi-touch gestures
  • Mobile game testing requiring precise touch sequences
  • Accessibility testing for touch-optimized interfaces
  • Web applications that have custom touch logic

Benefits

  • Parity - Brings touch API parity with existing mouse drag operations (mouse.down(), mouse.move(), mouse.up())
  • Developer Experience - Provides both high-level convenience methods and low-level control
  • Test Accuracy - Enables authentic simulation of real user touch interactions
  • Mobile-First Testing - Critical for organizations prioritizing mobile experience
Example

Proposed API

// High-level touch drag action with coordinates
await page.touchscreen.tapAndDrag(100, 100, 300, 300, { 
  steps: 10 
});

Low-level primitives

// Fine-grained control over touch sequences
await page.touchscreen.down(100, 100);
await page.touchscreen.move(150, 150);
await page.touchscreen.move(200, 200);
await page.touchscreen.up(250, 250);
Motivation

Currently, Playwright lacks native support for touch drag operations and low-level touch primitives. While touchscreen.tap() exists for simple touch interactions, there's no built-in way to:

  • Perform drag operations on touch devices - Essential for testing mobile applications with drag-and-drop interfaces, swipe gestures, and interactive elements.
  • Fine-tune touch interactions - Low-level primitives (down, move, up) enable precise control over complex gesture sequences.
  • Test mobile-specific UX patterns - Many mobile applications rely on drag gestures for core functionality (sortable lists, sliders, carousels, etc.).
  • Developers currently must work around this limitation using mouse events or complex workarounds that don't accurately simulate real touch behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the page.touchscreen API and the existing touchscreen.tap behavior, then compare it with mouse drag operations. Define and validate the high-level tapAndDrag action plus down, move, and up primitives for the touch interactions described, including coordinate steps and hasTouch scenarios.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
mobile-dev, testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.