XCUITest: `scroll(byDeltaX:deltaY:)` API is not available for iPhones.

In my XCUITest tests, I expected to be able to scroll elements in iOS >= 15 devices (with X,Y deltas) since it’s declared in the header file as:

/**
* Scroll the view the specified pixels, x and y.
*/
@available(iOS 15.0, *)
open func scroll(byDeltaX deltaX: CGFloat, deltaY: CGFloat)

However, in the documentation website (https://developer.apple.com/documentation/xctest/xcuielement/1500758-scroll) it says under “Discussion”:

Available in macOS and in iPadOS 15 and later.

No iPhones :( Although it says nothing under “Availability”.

Calling this action when running on iPhone simulator, indeed raises the error message:

Pointer events are not supported for this device.

I’d expect this action to work on iOS as well, and not only on iPadOS. But sadly, as I mentioned, it isn't.

I made some workaround to make this "work" (partially), using XCUICoordinate but I really don't like it (since it's impossible to find an hittable coordinate without guessing or using some messy heuristics that includes frames work) and would have been happy for something more elegant.

Is there any reasonable (elegant and accurate) alternative for this, that is scrolls based on X and Y deltas?

The scroll API outlined above triggers a trackpad two-finger swipe event, which would mimic the user scrolling on a Mac, or an iPad with a trackpad attached.

There is currently no such API for iOS, as there is no trackpad support on iOS.

Thanks for the answer, If I understand correctly, there's no other way to scroll on a screen with a specified delta. Using scrolling on iOS devices is also possible, so I don't understand why this API should be specific for devices with trackpads.

Scrolling on iOS is done with drag events as opposed to scroll events.

You should be able to mimic dragging on iOS using a coordinate drag between two points, relative to an element on screen: https://developer.apple.com/documentation/xctest/xcuicoordinate/3551692-press

You can create an XCUICoordinate using the coordinate method: https://developer.apple.com/documentation/xctest/xcuielement/1500960-coordinate

XCUITest: `scroll(byDeltaX:deltaY:)` API is not available for iPhones.
 
 
Q