Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeUp and Swiping Right not working correctly on XCUITest - M1 Mac

On an intel computer, my XCUITest test works perfectly fine to swipe left and swipe right on a cell using cell.swipeRight() or cell.swipeLeft().

On my m1 computer, cell.swipeLeft() works but cell.swipeRight() doesn't. I don't think it swipe right enough. If I manually do it on the simulator then it works to hide the elements shown on swipe; however the swipeRight function won't swipe it enough to hide the elements.

Note: i'm running the simulator using Rosetta. It works fine manually but not thru the XCTest functions

Does anyone have a solution for swiping right on the m1?

Also, swipeUp() on the Intel scrolls the table up a lot more than on the simulator using an m1 mac. It just moves the table up a little now.

like image 233
reutsey Avatar asked Dec 06 '25 02:12

reutsey


1 Answers

I don't have both machines so i can't replicate what's causing this, but i can offer you a workaround.

Use .press and define the swiping yourself.

let dragBegin = cell.coordinate(withNormalizedOffset: CGVector(dx: 0.1, dy: 0.5))
let dragEnd = cell.coordinate(withNormalizedOffset: CGVector(dx: 0.4, dy: 0.5))
dragBegin.press(forDuration: 0.1, thenDragTo: dragEnd)

Adjust dx for each CGVector as needed. These are coordinates are relative to the Cell (or any other XCUIElement) you're interacting with.

You can be very specific with this and even set velocity and holdDuration. (See Documentation)

P.s. Chances are this is Apples bug. Consider opening a Bugreport.

like image 142
gameshack_ Avatar answered Dec 08 '25 16:12

gameshack_



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!