Material-ui: Nightmare/Electron touch event

Created on 19 Oct 2016  路  5Comments  路  Source: mui-org/material-ui

Hi,
I'm currently experimenting with the test runner Nightmarejs and having a nightmare trying to simulate a touchTap on all MUI buttons.
I'm wondering if theres a particular way to deal with touchTap in Electron and also nightmare ?
I'v included

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

in my index.js and can happily click or touch tap those buttons in chrome/safari also via night watch via selenium.
But not in Electron with Nightmarejs ...
Any ideas would be hugely appreciated.
/Stephen.

bug 馃悰 external dependency

Most helpful comment

I found I am able to 'click' on the element programmatically with this code:

var t = new Touch({
    identifier: Date.now(),
    target: document.querySelector('button'),
    clientX: 100,
    clientY: 100,
    radiusX: 2.5,
    radiusY: 2.5,
    rotationAngle: 10,
    force: 0.5,
  });

var touchEvent = new TouchEvent('touchend', {
    cancelable: true,
    bubbles: true,
    touches: [t],
    targetTouches: [],
    changedTouches: [t],
    shiftKey: true,
  });

document.querySelector('button').dispatchEvent(touchEvent)

Many thanks to this StackOverflow comment for leading me to the answer: http://stackoverflow.com/a/42447620/935473

This can be closed.

All 5 comments

I am also having this same problem. No touchTap events work at all :(

+1

How does onClick behave?

onTouchTap is provided by an external dependency that has already been removed on next.

I am also experiencing this problem. Has anyone found a solution? I have the same use case as @maitriyogin with Nightmarejs.

I found I am able to 'click' on the element programmatically with this code:

var t = new Touch({
    identifier: Date.now(),
    target: document.querySelector('button'),
    clientX: 100,
    clientY: 100,
    radiusX: 2.5,
    radiusY: 2.5,
    rotationAngle: 10,
    force: 0.5,
  });

var touchEvent = new TouchEvent('touchend', {
    cancelable: true,
    bubbles: true,
    touches: [t],
    targetTouches: [],
    changedTouches: [t],
    shiftKey: true,
  });

document.querySelector('button').dispatchEvent(touchEvent)

Many thanks to this StackOverflow comment for leading me to the answer: http://stackoverflow.com/a/42447620/935473

This can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbozan picture rbozan  路  3Comments

activatedgeek picture activatedgeek  路  3Comments

reflog picture reflog  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

mb-copart picture mb-copart  路  3Comments