1

The XCUIElement.h class file shows
- (void)scrollByDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY; and
- (XCUICoordinate *)coordinateWithNormalizedOffset:(CGVector)normalizedOffset; functions. But these can't use on iOS device. XCUIElement.h provides - (void)swipeDown to swipe the tableview. Because of the insufficient distance to swipe down, pull-to-refresh framework just like MJRefresh can't be responded.
So how do I custom the location or use exist function to edit the swipe down distance?

Shuhari
  • 317
  • 1
  • 2
  • 10
  • "Swipe" is not a scroll. It should be used for swipe recognizers, not for scrolling. Therefore you cannot change the distance. Scrolling is one of the old pains of Apples UI Automation but see http://stackoverflow.com/a/33538255/669586 – Sulthan Jul 05 '16 at 14:13

1 Answers1

7

You can drop down to the coordinate APIs to perform a pull-to-refresh.

let firstCell = app.staticTexts["Cell One"]
let start = firstCell.coordinateWithNormalizedOffset(CGVectorMake(0, 0))
let finish = firstCell.coordinateWithNormalizedOffset(CGVectorMake(0, 6))
start.pressForDuration(0, thenDragToCoordinate: finish)

I've put together more information along with a working sample app on my blog.

Joe Masilotti
  • 16,815
  • 6
  • 77
  • 87
  • While this does work, it looks like scrolling its not file tuned. In your answer you have `(CGVectorMake(0, 6)`, but in my app it looks like scrolling just by 1 scroll too much. Is there more to `coordinateWithNormalizedOffset` ? Maybe i just dont know how it works. – Just a coder Apr 16 '20 at 16:55