cypress-real-events icon indicating copy to clipboard operation
cypress-real-events copied to clipboard

Implement in realClick, realSwipe, realTouch the support for percentages regarding x and y

Open silversonicaxel opened this issue 4 years ago • 2 comments

It should be possible to interact with those commands also with percentages

as an example

cy.get("body").realClick({ x: `10%`, y: `12%` })

cy.get("body").realSwipe({ x: `10%`, y: `12%` })

cy.get("body").realTouch({ x: `10%`, y: `12%` })

or to keep intact the current x and y it could be

cy.get("body").realClick({ xPercent: `10%`, yPercent: `12%` })

cy.get("body").realSwipe({ xPercent: `10%`, yPercent: `12%` })

cy.get("body").realTouch({ xPercent: `10%`, yPercent: `12%` })

silversonicaxel avatar Apr 19 '21 14:04 silversonicaxel

What is the use case?

dmtrKovalenko avatar Apr 19 '21 14:04 dmtrKovalenko

I actually need it for the Click, so maybe it could be ignored for Swipe, maybe it could make sense for Touch.

My use case is the following: I've a slider that occupies all the horizontal space of its container, it could be fullWidth. The slider handle can move on the slider bar with a drag and drop effect, or with a click to trigger anywhere in this horizontal slider bar.

I would love to decide the percentage because, having my e2e tests running on different viewports, the pixel definition is not really precise for many scenarios. And the percentage fits this perfectly.

Unless if you have a better approach with the current implementation, I'm open to a good solution. Thanks @dmtrKovalenko

silversonicaxel avatar Apr 19 '21 15:04 silversonicaxel