Testcafe: Mouse down, mouse up behaviour

Created on 18 Jan 2018  路  9Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

Feature request

What is the current behavior?

There is not possible to simulate long click action in testcafe environment, which means it is not possible to measure the time between mouse down and mouse up.

What is the expected behavior?

To simulate long click action as it is in reality, thus it would be possible to measure the total time between mouse down and mouse up.

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

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code


Specify your

  • operating system: Windows7
  • testcafe version: 0.18.6
  • node.js version: 8.9.3
level 2 enhancement

Most helpful comment

Is there a workaround available? I need to migrate the following from puppeteer to testcafe.

export async function drag([fromLeft, fromTop], [toLeft, toTop], page) {
  await page.mouse.move(fromLeft, fromTop, { steps: 10 })
  await page.mouse.down()
  await page.mouse.move(toLeft, toTop, { steps: 10 })
  await page.mouse.up()
}

All 9 comments

We would need such functionality as well. It might be good to have either possibility to do mousedown/mouseup in separate or, maybe even better, to add click options with the delay between mousedown/mouseup.

This option would be also useful in D&D functionality. I know use cases, used especially on touch devices, when Drag action is started some time after initial touchstart event to distinguish scroll start vs drag start.

Hi,

Thanks for the proposal.
Meanwhile, If you need to increase a delay between mousedown and mouseup try to set the speed option of the click action.

Thank you for your prompt reply. Unfortunately, the solution you recommend is not sufficient. I managed to simulate long press action by drag feature. The smallest value I was able to measure on the button was 0 seconds, the biggest one was 1 second. If I wanted to measure for example 5 seconds I wouldn't be able to do so. Anyway thank you for your answer and I will look forward that this feature will be possibly added to testcafe in the future.

I am looking for similar kind of functionality. Was going to put it as a new issue for extending the DragElement action, but I think having phases of the interaction (see below) split out would be useful.

So my example is trying to test first-draft - an online interactive drawing/annotation app. An example of the interactions I need to be able to test (more at https://gitlab.com/MeldCE/first-draft/issues/59#tool-use) is
l-mousedown, mousemove, shiftdown, mousemove, shiftup, mousemove, l-mouseup

While is probably quite an extreme case of needing to test interactions, it could be useful other places, eg testing a map fetches tiles as you pan around the map.

Having the ability to run assertions part way through an interaction would be super useful (eg dragging a file onto a div to ensure the drop target is showing) and I think this would only be possible if the individual phases were available (eg, mousedown, mouseup, mousemove). Doing this (with the addition of an interaction pause action) would also help solve #2803 and #1374.

There is also a case for doing the same (or making sure they are included) for touch and pointer events.

Maybe this would be too complicated and could be a separate module once #1535 is completed

@bytesnz
Thank you for an interesting suggestion. While we do not have plans to implement something similar in the near future, we will take your opinion into account when planning our future releases.
BTW, I think it's better to create a separate feature request for this.

Is there a workaround available? I need to migrate the following from puppeteer to testcafe.

export async function drag([fromLeft, fromTop], [toLeft, toTop], page) {
  await page.mouse.move(fromLeft, fromTop, { steps: 10 })
  await page.mouse.down()
  await page.mouse.move(toLeft, toTop, { steps: 10 })
  await page.mouse.up()
}

Thank you for creating a separate issue. Let's continue discussing your inquiry in the context of that thread: #5036.

Any luck @aaronshaf?

I'm evaluating TestCafe and don't think I can use it without this feature.

Is it something you'd like the community to build out for you?

@seanpoulter No luck yet. Would love a solution.

Was this page helpful?
0 / 5 - 0 ratings