4

I'm currently working on an automation script (JavaScript) for an iOS app. I'm not a programmer, just a tester who wants to seek bugs.

Software concerned: Xcode, Instruments.

Here is the problem: there are buttons in my application that had no name, which is important for automated tests, so I gave them a Label in the Accessibility field of Xcode. But Instruments still doesn't recognize the name of the buttons.

e.g.: What I want, but doesn't work:

target.frontMostApp().mainWindow().scrollViews()[2].buttons()["Settings"].tap();  

What I don't want, but works:

target.frontMostApp().mainWindow().scrollViews()[2].buttons()[1].tap();

This is just one of many situations I've encountered. I chose a simple one and it could seem trivial, but some others are really problematic.

Any idea how to fix this?

  • I had the same problem. Looking forward to an answer to this one... – Mick F Mar 21 '12 at 09:38
  • I also tried to update the label of the Identity field. Still nothing. And I add that VoiceOver says "Settings button" when I touch the icon. :/ – Yvan Moullec Mar 21 '12 at 16:37

1 Answers1

0

Do you create the code by typing it, or do you capture it?

If you havn't captured it: you can do that by using that small record button in the JavaScript editor. After capturing, Instruments shows you the code, that would automate the actions you did "by hand". Then you can find out, if there is a different way to adress the button. This way you can find out how to trigger your button I havn't set up my GUI elements with the acessibility properties, because this way I can find out how to trigger the elements.

It sometimes takes a few tries to get things running.

enter image description here

Also, if an animation is applied when the screen is changing, a delay is needed before you can trigger the next GUI event:

target.delay(1);

This creates a delay of 1 second until the next event is fired.

Hope this helps

brainray
  • 12,512
  • 11
  • 67
  • 116
  • Hi brainray, and thank you very much for answering. Yes I did try to capture and it didn't display the right name (just a number) but it works today (yes, really works). And it seems that the Instruments file I used to open to write my scripts was corrupted. I created a new session on Instruments and imported my js scripts, and it works. Thank you for the scrolling menu tip and the delayer though, it will be very useful. – Yvan Moullec Mar 22 '12 at 09:35
  • I have a lots of problems with Instruments-files as well. Meanwhile I create a new one every now and then. Apparently they don't have long lives.. – brainray Mar 22 '12 at 17:12