在XCode Instruments中,有没有办法通过Javascript在运行时找到iOS版本的Simulator

时间:2014-10-03 16:04:26

标签: ios xcode ios-simulator instruments ios-ui-automation

执行自动化测试用例时,iOS 7.x与iOS 8.x中要选择的对象(“点击”)不同,即使开发人员没有专门为不同的iOS版本更改代码。我不是在try catch块中执行步骤,而是查询模拟器的iOS版本并执行正确的步骤。

对于iOS 8,步骤如下所示:

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

对于iOS 7,步骤如下:

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

基本上,segmentedControls已被添加。

有没有办法在自动化脚本的运行时检查模拟器的iOS版本?

1 个答案:

答案 0 :(得分:1)

你可以做出这个决定的事情是:

  1. SIMULATOR_RUNTIME_VERSION环境变量
  2. 系统库的当前版本
  3. 使用#1可能更容易。