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

Click simulates two pointerup events on Android #4837

Closed
0815Strohhut opened this issue Mar 3, 2020 · 9 comments
Closed

Click simulates two pointerup events on Android #4837

0815Strohhut opened this issue Mar 3, 2020 · 9 comments
Labels
SYSTEM: automations TYPE: bug The described behavior is considered as wrong (bug).

Comments

@0815Strohhut
Copy link

What is your Test Scenario?

We have a page that has an element with both an onTap and an onDoubleTap handler using react-hammerjs. I created a sandbox to show the situation.

Then use Testcafe to simulate a "click" on the div.

What is the Current behavior?

On desktop browsers and iOS: the tap counter is increaed by 1, all is fine.
On Android devices: the tap counter is increased by 2, the double tap counter is increased by 1 (tested with Samsung Galaxy Tab S5e with Andoid 9 and some Huawai Tablet running Android 7)

What is the Expected behavior?

Android devices should simulate a single tap.

What is your web application and your TestCafe test code?

The following code for Testcafe will do the trick using the sandbox above:


fixture("Bug Repro")
  .page(`https://rmkpd.csb.app/`)
  

test("Double Click on Android", async t => {
  const clickable = Selector("#clickme");

  const taps = Selector("#taps");
  const doubleTaps = Selector("#doubletaps");

  await t.click(clickable);

  await t.expect(taps.textContent).eql("1");
  await t.expect(doubleTaps.textContent).eql("0")
});

Note that if you access the page without Testcafe, taping/clicking the "clickme" div works as expected also on Android devices.

Your Environment details:

  • testcafe version: 1.8.2
  • node.js version: 12.13.1
  • browser name and version: Chrome 78.0.3904.62 / Android 9
  • platform and version: Android 9 / Android 7 (didn't test the other andoid versions)

I'd be happy about any ideas/input/possible causes you can give me as I have spend quite some time already investigating this and don't have any idea what's the issue. As we have quite some double-taps in our code, that breaks a lots of our tests for andoid devices.
It would for example be helpful to get some info how I can debug the code of testcafe itself while running my test to get an idea of whats happening in that scenario.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 3, 2020
@miherlosev
Copy link
Collaborator

Hi @0815Strohhut,

Could you please clarify how you run TestCafe tests on an Android device?

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 5, 2020
@0815Strohhut
Copy link
Author

Hi @miherlosev ,

I am running testcafe on a Windows 10 machine while
a) using browserstack with the testcafe-browserstack-provider for the Samsung Galaxy Tab S5e (or any other device available there)
b) using the option "remote" and accessing the given browser url from the Huawai Tablet running Android 7 (which is actually the only "real" device I have available/connected to our infrastructure)

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 5, 2020
@miherlosev miherlosev added TYPE: bug The described behavior is considered as wrong (bug). SYSTEM: automations labels Mar 5, 2020
@miherlosev
Copy link
Collaborator

I've reproduced the problem. Thank you for the detailed information.
To debug how TestCafe performs the click action, do the following:

  • open the node_modules\testcafe\lib\client\automation\index.js file
  • find the ClickAutomation.prototype.run = function run(useStrictElementCheck) function.
  • insert a debugger statement at start of it
  • run TestCafe in development mode.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 5, 2020
@0815Strohhut
Copy link
Author

Thanks a lot for the info, I did some investigation and came to the conclusion, that pointerevents seem to be the problem here.

I took a deeper look into what Hammerjs is actually doing and noticed that it uses the pointerevents to detect a doubletap. Hence, I simplified the sandbox to show the issue without hammerjs.

Accesing the page using a real device, we get exactly one pointerup event when we press the "clickme" div. However, accessing the page using testcafe

fixture("Bug Repro")
    .page(`https://1bq90.csb.app/`)
  

test("Pointer Events on Android", async t => {
  const clickable = Selector("#clickme");
  const pointerups = Selector("#pointerup");

  await t.click(clickable);

  await t.expect(pointerups.textContent).eql("1");
});

we get two pointerup events on android devices. On ios safari or desktop devices, we still get one pointerup event.

As far as I can see, Testcafe simulates the "normal" chain of touchstart, touchend, mousedown, mouseup and click. My guess would be that for some reason the Chrome browser maps this to two seperate pointer-event sequences (one for the touchstart+end, one for mousedown + up) - but it is just a guess, I wasn't able to find reliable information on it.

Disabling the pointer event handling of hammerjs solves the problem (falling back to handling mouse/touch events).

However, as by now pointer events are supported accross all browsers supported by Testcafe, I feel like Testcafe should probably be able to deal with/simulate pointer events as at least I would expect that we will see more people handling pointer events in the future? It feels like a rather large change to me though.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 7, 2020
@0815Strohhut 0815Strohhut changed the title Click is simulated as DoubleTap on Android Click simulates two pointerup events on Android Mar 7, 2020
@AlexSkorkin
Copy link
Collaborator

Thank you for sharing your findings with us. Please give us additional time to discuss them.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 9, 2020
@AlexSkorkin AlexSkorkin added the STATE: Need response An issue that requires a response or attention from the team. label Mar 9, 2020
@Dmitry-Ostashev Dmitry-Ostashev removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 10, 2020
@HessleHuijser
Copy link

HessleHuijser commented Sep 20, 2021

ran into the same problem today. t.dragToElement(element, element); worked as a temporary solution for both my test and the sandbox @0815Strohhut provided.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 20, 2021
@Farfurix
Copy link
Contributor

@HessleHuijser

Thank you for sharing your workaround.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 22, 2021
@miherlosev miherlosev assigned miherlosev and unassigned miherlosev Dec 15, 2021
@miherlosev
Copy link
Collaborator

#4837

For the team:

To reproduce the issue without using a real device, use device emulation.

Run the test

import { Selector } from 'testcafe';

fixture("Bug Repro")
    .page(`https://1bq90.csb.app/`)


test("Pointer Events on Android", async t => {
    const clickable = Selector("#clickme");
    const pointerups = Selector("#pointerup");

    await t.click(clickable);

    await t.expect(pointerups.textContent).eql("1");
});

two times with the following commands:

testcafe chrome test.js
testcafe "chrome:emulation:device=pixel 2" test.js

@Aleksey28
Copy link
Collaborator

Fixed in PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SYSTEM: automations TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

7 participants