XCUITest - Unable to find image hit point using iOS 11

Since iOS 11 XCUITest can no longer find hitpoints for UIImages, which leads to the fact that you cannot click on the image or drag it onto it using press(forDuration:thenDragTo:).

There is a workaround for clicking an image that works (using tapon coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))). The same approach does not work for the method thenDragTo, since it expects an XCUIElement.

Does anyone have an idea how to make the thenDragTo method work (preferably without having to edit the production code)?

Thanks in advance

+4
source share
1 answer

It accepts XCUICoordinate in my tests in Xcode 9.2

extension XCUICoordinate {
    open func press(forDuration duration: TimeInterval, thenDragTo otherCoordinate: XCUICoordinate)
}

I can use it as follows:

let fromCoordinate = contentElement.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
let toCoordinate = fromCoordinate.withOffset(CGVector(dx: 0, dy: 260))
fromCoordinate.press(forDuration: 0.01, thenDragTo: toCoordinate)
+1

Source: https://habr.com/ru/post/1690058/


All Articles