Skip to content

[Bug]: mock mobile device in chrome/chromium, open a video page, can not scroll to next page or next video #3009

@conhaifeng

Description

@conhaifeng

Version

1.55.0

Steps to reproduce

  1. open the target url in chromium, mock iPhone 13
from playwright.sync_api import sync_playwright, Playwright

iphone_13 = playwright.devices['iPhone 13']
browser = playwright.chromium.launch(headless=False)
context = browser.new_context(
	**iphone_13,
)
page = context.new_page()
url = "https://m.toutiao.com/video/7578574827087216640"
page.goto(url)
  1. try to scroll to next video in this page by mouse or pan by locator, like below
def pan(locator, deltaX=0, deltaY=0, steps=5):
    bounds = locator.bounding_box()
    centerX = bounds['x'] + bounds['width'] / 2
    centerY = bounds['y'] + bounds['height'] / 2

    touches = [{
        'identifier': 0,
        'clientX': centerX,
        'clientY': centerY,
    }]
    locator.dispatch_event('touchstart', {
        'touches': touches,
        'changedTouches': touches,
        'targetTouches': touches
    })

    for i in range(1, steps + 1):
        touches = [{
            'identifier': 0,
            'clientX': centerX + deltaX * i / steps,
            'clientY': centerY + deltaY * i / steps,
        }]
        locator.dispatch_event('touchmove', {
            'touches': touches,
            'changedTouches': touches,
            'targetTouches': touches
        })

    locator.dispatch_event('touchend')
  1. ignore the video can not play error,

Expected behavior

  1. I can scroll to next video

Actual behavior

  1. can not scroll to next video
    mock iPhone13
    is_mobile: True
    has_touch: True
    2.debug by F12, when i scroll, only MouseDown event, no TouchStart event

Additional context

1.when i mock iPhone13 by chrome: F12 -- Toggle device toolbar -- select iPhone 13 or any other device, i can scroll to next video. so it is mostly sitll web mode when use playwright mock iPhone13

Environment

- Operating System: [window10]
- CPU: [arm64]
- Browser: [Chrome, Chromium, WebKit]
- Python Version: [3.10]
- Other info:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions