Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在XCode Instruments中,有没有办法通过Javascript在运行时找到模拟器的iOS版本_Ios_Xcode_Ios Simulator_Instruments_Ios Ui Automation - Fatal编程技术网

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

在XCode Instruments中,有没有办法通过Javascript在运行时找到模拟器的iOS版本,ios,xcode,ios-simulator,instruments,ios-ui-automation,Ios,Xcode,Ios Simulator,Instruments,Ios Ui Automation,在执行自动测试用例时,要选择的对象(“点击”)在iOS 7.x和iOS 8.x中是不同的,即使开发人员没有专门为不同的iOS版本更改代码。我宁愿查询模拟器的iOS版本并执行正确的步骤,而不是在try-catch块中执行该步骤 对于iOS 8,步骤如下所示: UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].segmentedControls()[0].buttons()["Exp

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

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

UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].segmentedControls()[0].buttons()["Expanded"].tap();
UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].buttons()["Expanded"].tap();
对于iOS 7,步骤如下所示:

UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].segmentedControls()[0].buttons()["Expanded"].tap();
UIATarget.localTarget().frontMostApp().mainWindow().collectionViews()[0].cells()[1].buttons()["Expanded"].tap();
基本上,添加了分段控制


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

您可以通过以下方式进行确定:

  • 模拟器\u运行时\u版本环境变量
  • 系统库的当前版本

  • 使用#1可能更容易。

    谢谢,但是如何从UIATarget获取此变量的值呢。例如,var target=UIATarget.localTarget();UIALogger.logMessage();您是否尝试过UIATarget.localTarget().systemVersion()?我认为这将返回正确的iOS版本。如果没有,请向谢里米发送雷达,就这样!