Search code examples
iphoneios4instrumentsios-ui-automation

Unexpected Error in Instruments using UIAutomation


I am currently using IOS SDK 4.0.2 and learning how to do UIAutomation. Unfortunately I found that in the Simulator, when I try running a simple Java script test (that just assigns variables) I get the following error.

Unexpected error in -[UIATarget_0x5d04f60 frontMostApp], /SourceCache/UIAutomation_Sim/UIAutomation-37/Framework/UIATargetElements.m line 437,

Here is the "Script" I was trying to run

   function iDontDoAnything() {
      var target = UIATarget.localTarget();
      var app = target.frontMostApp();
      var navBar = app.navigationBar();
      UIALogger.logPass("it passed");
}

  UIALogger.logStart("First Tester Test");
  iDontDoAnything();

And I figured out that this is because I am getting a null returned when frontMostApp() is called. The test runs fine/passes on the actual device with 4.0.2.

Main Question: Is there a way to solve this problem in 4.0.2 on the simulator? I have noted a solution for the earlier version (4.0.1) that had this problem - tried it with no success.

Not much documentation out there yet, any advice would be much appreciated!

Lauren


Solution

  • Did you check if simulator has the accessibity.plist?

    I found this on https://devforums.apple.com/message/261883#261883 they recommend: "Copy ~/Library/Application Support/iPhone Simulator/4.0/Library/Preferences/com.apple.Accessibility.plist to ~/Library/Application Support/iPhone Simulator/4.0.1/Library/Preferences" and it worked for me.