真的就是亂寫用的筆記

UI Automation

iOS 4.0 adds the UI Automation feature, it is a cool stuff. UI Automation allows you to run Javascript code when you are running your iPhone application with Instrument, therefore you can do UI tests automatically, you can know what happens if a button is tapped programmatically.

I played with the feature yesterday, and I suddenly found some problems.

First, UI Automation does not work on the iPhone Simulator. When you start to test your UI with your Javascript code, you have to call UIATarget.localTarget().frontMostApp() to obtain the object which represents your currently running application. The Javascript call returns null on iPhone Simulator, so you are unable to do anything further.

UI Automation does not work on my iPhone 3G, too. Instrument told me that my device is not supported. I finally ran my code on a newer model of iPad Touch, and I guess my iPhone 3G is already obsolete for contemporary iPhone software development. Well, only two years went by, the model has become so old. Gee!