Search code examples
iosxcodeios-simulatorinstrumentsios-ui-automation

In XCode Instruments, is there a way to find the iOS version of the Simulator at runtime via Javascript


When executing an automated test case, the object to be selected ("tapped") is different in iOS 7.x vs iOS 8.x, even though the developer didn't change code specifically for the different iOS versions. Instead of executing the step in a try catch block, I'd rather query the simulator for iOS version and execute the correct step.

For iOS 8, the step looks like this:

UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].segmentedControls()[0].buttons()["Expanded"].tap();

and for iOS 7, the step looks like this:

UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].buttons()["Expanded"].tap();

Basically, segmentedControls was added.

Is there a way to check the iOS version of the simulator at run time of the automation script?


Solution

  • The things available to you to make this determination would be:

    1. SIMULATOR_RUNTIME_VERSION environment variable
    2. Current versions of system libraries

    Using #1 is probably easier.