Question

I'm trying to write some UIAutomations for an ios app. Every piece of UI in this application is custom. When using the recorder in UIAutomation, I can choose buttons based on their index. Such as ....

UIATarget.localTarget().frontMostApp().mainWindow().buttons()[1].tap();

Now, some buttons, when pressed with the recorder, show up like this...

UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Edit"].tap();

My question is, what do I need to do in the code to uniquely identify every button like how the "Edit" button is identified above. I know this isn't using the tag property because tags must be integers and I just tried to set the accessibiltyIdentifer on a button. However the NSString I used for the accessibiltyIdentifer didn't let me access the button in UIAutomation with that string. So what was done to this "Edit" button that let me access it that way? I'm working in a large code base that I'm very new to so I'm a little lost.

Was it helpful?

Solution

Looks like you want to set both accessibilityEnabled to YES and accessibilityLabel.

myTextField.accessibilityEnabled = YES;
myTextField.accessibilityLabel = @"User Text";

Source - http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top