Using the UI Automation instrument, I know how to test if a particular button is enabled in my iOS application:
if( btn[0].isEnabled() ) {
UIALogger.logPass("button enabled");
} else {
UIALogger.logFail("button not enabled");
}
However, I’d like to be able to determine the number of buttons that have been enabled in the interface, not just whether a specific one is enabled. How could I determine the number of enabled buttons?
Also, how do I print details of these buttons to the console?
Here’s a function which takes a UIAElementArray (ie app.mainWindow().buttons()) and logs the number of enabled buttons:
Example calling code: