I am trying to write a UI Test in Xcode for dragging a dot around the screen. The test had been working for weeks, but as soon as I put text behind the starting position of the dot, the UI Test is no longer able to drag the dot around (even though it's totally draggable in the actual app!). I’m using SwiftUI to develop the app. Why is this happening?
Code:
func testShouldDragDot() throws {
let endLocation = app.otherElements["endLocation"]
let thankYouText = app.staticTexts["thankYouText"]
let dot = app.otherElements["dot"]
dot.press(forDuration: 1, thenDragTo: endLocation)
XCTAssertEqual(thankYouText.label, "Thank You")
}
Without text behind dot, it works fine:
But with text behind dot, the test fails: