Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to detect touchable device #2448

Closed
ferencbeutel4711 opened this issue May 22, 2018 · 5 comments
Closed

Unable to detect touchable device #2448

ferencbeutel4711 opened this issue May 22, 2018 · 5 comments
Assignees
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).

Comments

@ferencbeutel4711
Copy link

ferencbeutel4711 commented May 22, 2018

Are you requesting a feature or reporting a bug?

thats a good question, probably reporting a bug

What is the current behavior?

There seems to be no way to correctly detect a touchable device when using chrome mobile emulation

What is the expected behavior?

'ontouchstart' in window

returns true when chrome mobile emulator is used

How would you reproduce the current behavior (if this is a bug)?

  console.log(`touch? ${await testcafe.eval(() => {
    return 'ontouchstart' in window;
  })}`);

run testcafe with chrome mobile emulation (tested with iphone X)

Specify your

  • operating system:
    tested on osx 10.13.12 and ubuntu 16.04
  • testcafe version:
    0.19.2
  • node.js version:
    8.9.1
  • chrome version:
    66.0.3359.139

Hello there,

our application is detecting touch devices to run different javascript code for the page initialization. We want to test that the touchable version is working fine using testcafe. In order to detect a touch device, we use the following logic:

((("ontouchstart" in window ||
                        !!(window.DocumentTouch && document instanceof DocumentTouch) ||
                        window.navigator.maxTouchPoints)) && 
                        !window._phantom && !window.phantom) ? true : false;

This works fine in the chrome devtools for example. Select a mobile device, reload the page and executing the code will return true.
However, when we use chrome mobile emulation provided by testcafe, the code returns false and there seem to be 0 registered touch event listener in the document.

Is there a better way to detect touch devices or is this an issue with testcafe mobile emulation?

@ferencbeutel4711 ferencbeutel4711 changed the title Unabble to detect touchable device Unable to detect touchable device May 22, 2018
@miherlosev miherlosev self-assigned this May 22, 2018
@miherlosev miherlosev added the TYPE: question The issue contains a question that won't be addressed. label May 22, 2018
@AndreyBelym
Copy link
Contributor

Hi @ferencbeutel, could you please specify your TestCafe (you can get it with testcafe -v) and Chrome versions?

@AndreyBelym AndreyBelym added STATE: Need clarification An issue lacks information for further research. and removed TYPE: question The issue contains a question that won't be addressed. labels May 23, 2018
@ferencbeutel4711
Copy link
Author

Hi @AndreyBelym, I am using testcafe 0.19.2 and chrome version 66.0.3359.139.

@AndreyBelym
Copy link
Contributor

I've reproduced it in the latest TestCafe and Chrome. Looks like commands required to start touch emulation changed again, I'll fix it today.

@AndreyBelym AndreyBelym added TYPE: bug The described behavior is considered as wrong (bug). SYSTEM: browser natives AREA: server and removed STATE: Need clarification An issue lacks information for further research. labels May 24, 2018
@ferencbeutel4711
Copy link
Author

Hey @AndreyBelym, thanks for your quick response!
Sorry to hear that the chrome api seems to be so unstable.

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
…vExpress#2454)

* Fix touch emulation in the recent Chrome

* Add a test

* Use about:blank

* Update index-test.js

* Fix test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants