Reputation: 949
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:
The highlighted button is the button I would like to tap.
Upvotes: 2
Views: 2395
Reputation: 949
I just solved the problem. It was just that the button I was trying to tap was not visible. I checked with .isVisible()
and it returned false. Thanks for the help.
Upvotes: 2
Reputation: 1341
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.
Upvotes: 1