Search code examples
javascriptinstrumentsios-ui-automationxcode-instruments

How to tap a button in UI Automation which has only coordinates?


I only have the coordinates of the button :

UIAButton:rect:{{253,27},{60,30}}

which I have stored in an array. I want to tap this button particularly without giving its coordinates so that it is generic for the remaining buttons.

Thank you.


Solution

  • I would do something like what is shown in this question.

    UIATarget.localTarget().frontMostApp().tapWithOptions({tapCount: 1, tapOffset: {x: 0, y: 0});
    

    You'd replace the zeros in tapOffset with your desired x and y values.