Puppeteer: In page.emulate(option), option. hasTouch not worker

Created on 18 Oct 2017  路  3Comments  路  Source: puppeteer/puppeteer

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

_Please include code that reproduces the issue._

  1. prepare the demo like beblow:
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const browser = await puppeteer.launch({headless: false});
  const page = await browser.newPage();
  await page.emulate(devices['iPad landscape']);
  await page.goto(REDIRECT_URL);
  1. interact with the page in the chrome

What is the expected result?
touch operations work

What happens instead?
touch operations don't work

Most helpful comment

This should work.

const devtoolsProtocolClient = await page.target().createCDPSession();
await devtoolsProtocolClient.send("Emulation.setEmitTouchEventsForMouse", { enabled: true });

All 3 comments

Emulating a touch device with Puppeteer sets up the page so that something like modernizr will detect touch support. It doesn't convert mouse clicks into touch events. You can use page.touchscreen to send automated taps into the page.

This should work.

const devtoolsProtocolClient = await page.target().createCDPSession();
await devtoolsProtocolClient.send("Emulation.setEmitTouchEventsForMouse", { enabled: true });

@actionnick it work fine for me,thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mityok picture mityok  路  3Comments

aslushnikov picture aslushnikov  路  3Comments

sradu picture sradu  路  3Comments

ngryman picture ngryman  路  3Comments

paulirish picture paulirish  路  3Comments