vectorcoordinatesxcuitest

XCUITest coordinate(withNormalizedOffset:) explanation


I need the detailed information about coordinate(withNormalizedOffset:) method.

The information provided in the Apple's docs are very minimal.

This method is all about picking a specific point in the window. But how can I define dx & dy points for a specific point?

Consider the four corners of the window. Top Left, Top Right, Bottom Left, Bottom Right. Can someone provide details on this?


Solution

  • Range of dx & dy is 0 to 1 allowing float values. Normalized Offset is the x and y coordinates w.r.to the width and height of the object respectively.

    Say we have an object of width 245 and height 432, and we need coordinate (10, 34) on it. The normalized offset is (10 / 245, 34 / 432) i.e. (0.040816327, 0.078703704) where the actual offset is (10, 34).