我关注这个网站是为了开始使用 UI 自动化。http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation#1.2 http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation#1.2
我正在尝试从命令行启动 Instruments。不幸的是我收到一个错误:
2013-03-14 14:06:36.376 instruments[17854:1207] Connection to the remote device lost while launching target. Aborting...
2013-03-14 14:06:36.378 instruments[17854:1207] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Failed to start trace.
这是我使用的命令:
instruments -w {deviceId} -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate {appname} -e UIASCRIPT /Path/to/Script.js
目前我使用的是 Xcode 4.6。
在 2014 年使用 Xcode 6.0.1 时,您可以执行以下操作在模拟器上运行 UIAutomation 测试,并在 -w 开关后命名您的模拟器:
instruments -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
-w 'iPhone 5s' \
'/Users/sohail/Library/Developer/CoreSimulator/Devices/7232A640-A9D2-4626-A2AD-37AFFF706718/data/Containers/Bundle/Application/E71B915E-051D-4BEF-9083-34416D02EC91/RoadRunnerRadar.app' \
-e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
-e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'
如果您想在您的设备上运行此程序,而不是像上面代码片段中那样在模拟器上运行“iPhone 5s”,您需要提供设备的 UDID。然后,您可以省略我上面给出的长应用程序路径,而只提供应用程序的名称。仪器将能够在设备上找到它。
使用上面的示例,但针对假设的设备进行了修改,这看起来像:
instruments -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
-w '8532A640-A9C2-4626-A2AD-37AFFF706799' \
'RoadRunnerRadar' \
-e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
-e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'
这未通过设备上调用进行验证,因此请对其进行测试。参数排序有一定的灵活性。
我确实有一个经过验证的UI 自动化运行器 http://sohail.io/2014/09/20/xcode-6-and-running-uiautomation-test-from-the-command-line/非常适合 Xcode 6.0.1 和模拟器的脚本。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)