十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

iPhone自动化测试

上一篇 / 下一篇  2011-11-16 22:49:57 / 个人分类:自动化测试

文章来源
  • 文章来源:【转载】

2A D4T%s:N K0以下是同事做的基本研究。做了一下测试,还是可以的。更多的功能需要花时间去研究。

Nby opiW+fMH051Testing软件测试网D/^3k"iKet@Pa-a

设置方法:

P3ybOY2}l"c051Testing软件测试网w3m4sz G tb4]

1)在Mac上安装Xcode和iPhone SDK,最好是最新版本。51Testing软件测试网Yj2~P9I'VK w

AKt4h*E7oR.A02)打开/Developer/Applications/Instruments.app,在模版的列表里面选择iOS的All,然后选择Automation模版。51Testing软件测试网!E(KkFlS3gj

z.xJw \XS1c2Q03)连接iPhone到Mac,然后在Instruments主面板选择“Choose Target”下拉菜单并选择已连接的iPhone,接着选择“Choose Target”选项并选择需要测试的应用程序。

*E,q(soMF d%Ta,Z051Testing软件测试网"Ex7wn1Z.IkG.m'\/[-r

4)在Instruments主面板左边选择“Choose Script…”下拉菜单并选择一个已经编写好的JavaScript命令脚本(后缀为.js,如需要修改可点击旁边的“Edit”按钮)51Testing软件测试网 E4M#|3I(q'D9\I

51Testing软件测试网xC)y#e `&Md(Lm

5)点击“Record”按钮即可开始自动测试。自动测试开始之后不会自动停止,需要手动点击“Stop”按钮停止。51Testing软件测试网:v \e1k9@-S(a

51Testing软件测试网U&pOR6P

 

D8[2B8E.Lp051Testing软件测试网fgm?8yG,iP-q:N

可用命令脚本例子:

4e~:H'q3Z.UqT$P051Testing软件测试网 n5jc&US+r'X3l0d

UIATarget.localTarget().frontMostApp().mainWindow().buttons()[0].tap();51Testing软件测试网X)I@-jy;~*p

51Testing软件测试网h4@-jJ7D K

意思是点击你软件界面上的第一个按钮

!?9`2@2zb}.F0G6C051Testing软件测试网Re'n9w%eZ&N

 51Testing软件测试网-j!c4_Zj"{C{1Q+a$?

51Testing软件测试网"s'Izb jdO

 51Testing软件测试网|+S hB?3U v9s)y3`s#p

51Testing软件测试网!XVR4huA#G o z JY

可能出现的问题1:51Testing软件测试网2Um/U7e~7\"J

{d@9W"zqt1O6@0无法取得任务,出现“Target failed to run: Remote exception encountered: 'Failed to get task for pid ###'”错误提示。51Testing软件测试网Q2E,U_x6G)IL

51Testing软件测试网+LN}@)Ev)sB{q'^

 

e*L#@at O6xUt0

5w,zO3Ix5{EP5S0原因:51Testing软件测试网G d a fX H}

7D"LIVH0Build好的应用程序之中缺少Entitlements.plist。

sx;K}r+z051Testing软件测试网ba/@0f5Y1s1@*p

 51Testing软件测试网;m yQ+j*ws s\1H

uL\ t3L X0解决方法是添加一个带“Can be debugged”的Entitlements.plist:51Testing软件测试网8OP(f5}(@lO0n7T;F8W

51Testing软件测试网-\x4V_]~

1)用Xcode打开Project,在主面板左边“Groups & Files”列表中选择要测试的应用程序 》 Resources

x#kw3Aowa\f0

G3l8t1~KI B8V$gc02)选择File 》 New File…,接着在左边的列表中选择iOS的Code Signing并选择“Entitlements”,然后点击“Next”按钮,“Finish”按钮。

6poTT|4tQz051Testing软件测试网pR/H6K"yz

3)用/Developer/Applications/Utilities/Property List Editor.app打开Entitlements.plist,然后选择View 》 Property List Type 》 iPhone Entitlements plist

Ae(|EsD0

oE&k;D&p ?.nS04)在Property List Editor.app主面板中,选择iPhone Entitlements然后点击工具栏中的“Add Child”并添加“Can be debugged”选项,然后在Value中打勾,然后保存。51Testing软件测试网8NAL}2q/H4ec)A

51Testing软件测试网-W5H;_W'M/g

5)在Xcode中,选择Project 》 Set Active SDK 》 Device,接着选择Project 》 Set Active Build Configuration 》 Debug

slQ"GV7A6o0T051Testing软件测试网 cPhd3VR Qu9n

6)以上做完之后就Build应用程序并同步到iPhone里面。在添加Entitlements.plist过程中如果出现无法Build或者无法同步到iPhone的情况,很有可能是证书和预置文件的原因,确保证书和预置文件有效并正确导入。51Testing软件测试网J3r7A-S3@6Zm$PA

51Testing软件测试网,E t}v5oi-x$bY!i

 51Testing软件测试网"fo(k*M+n8N[0t

51Testing软件测试网1Hu:i"X6]K%eyQU

成功运行的软件版本:51Testing软件测试网I%^(sl/O&r_n

)sNCrg'\0Instruments 2.7(3017)51Testing软件测试网 s:scI9P

q5{TB/sh`j3D*y0Xcode 3.2.5
hT `h/C @` @051Testing软件测试网3yLeUWi

51Testing软件测试网)`(~*?9I/] jE0k%v

 

8MidMQ&X0

TAG: iphone iPhone 自动化测试

 

评分:0

我来说两句

Open Toolbar