Xcuitest: tapping at a specific location using x y coordinates not triggering the controls at that location

25 Views Asked by At

A simple iPad application has only a UIbutton. If tapping it will change its background color. If tapping happens outside the button the background of the application changes.

Now I’m trying to tap on the button using the x and y coordinates of the button. I do not see any change in the background of the button or even the background color of the application.

Code for Reference:

func testElementsOfMainScreen() {
     
    let app = XCUIApplication()
     
    let buttonFrame = app.buttons["AutoTap"].frame

    let buttonX = buttonFrame.origin.x
    let buttonY = buttonFrame.origin.y
     
    let tapCoordinates = CGVector(dx: buttonX+5, dy: buttonY+5)
    let coordinate = app.coordinate(withNormalizedOffset: tapCoordinates)
     
    coordinate.tap()
}
0

There are 0 best solutions below