Search code examples
iosfunctional-testingios-ui-automationautomated-tests

Tap command on a button not working in UIAutomation


I have this button in an app. I want to simulate a tap on the button. The button is located as follows: target>frontMostApp()>windows()[0]>buttons()[2]. My javascript code is as follows: target.frontMostApp().windows()[0].buttons()[2].tap(); But after running the code, the following error message is shown:

Error: target.frontMostApp().windows()[0].buttons()[2] could not be tapped

I have checked that the accessibility label of this button is set to enabled. Can anyone tell me what I am doing wrong? Below is a screenshot from the instruments console:

enter image description here

The highlighted button is the button I would like to tap.


Solution

  • Can you run logElementTree() on the window and paste that in to your question? That error usually means that the element you are looking for isn't valid. Maybe we can help discover the problem by looking at the element tree together.