Script 1.8.1
- 脚本语言
- 设备对象获取
- Device.getMain
- Device.searchObject(<DeviceName>)
- Device.searchObject(sigmaConst.DevAll)
- Device.searchObject(sigmaConst.DevGroup, <GroupName>)
- Device.searchObject(sigmaConst.DevSerial,<Serial>)
- Device.searchObject(sigmaConst.DevSelectOne)
- Device.searchObject(sigmaConst.DevSelectMult)
- Device.searchObject(sigmaConst.DevSelectGroup)
- 设备属性值
- 设备控制接口说明
- 公共接口说明
- 快捷键定义接口
- MTE说明
- getPixelColor
- getPixelColorStr
- runCTest
- runDTest
- setMessage(对象成员函数)
- setMessage(非对象成员函数)
- setStatus(对象成员函数)
- setStatus(非对象成员函数)
- stop(对象成员函数)
- Testrun(对象成员函数)
- Color
- setName
- Coord
- ImageInfo
- define
- lastError
- readExcel
- scriptKill
- scriptKillAll
- scriptList
- getLanguage
- scriptRun
- sigmaLoad
- screenshot
- seekColor
- seekImage
- seekImageByID
- send
- sendMessage
- setName
- setVolumes
- shift
- runApp
- swipe(coordArray)
- upload(fpath,tpath,timeout)
- unlock
- sleep()
- uninstallAPK(packageName)
- wakeup()
- deleteListener
- getNotification
- Notification
- reset
- swipe
- uninstallAPK
- unlock
- upload
- uploadTessData
- wakeup
- writeFile
- sleep
- click(x,y)
- closeApp(packageName)
- download(fpath,tpath,timeout)
- inputText(text)
- installAPK(apkPath)
- lock(timeout)
- runApp(packageName)
- screenShot(path,imageType,tx,ty,bx,by)
- send(key)
- exit
- execCommand
- execCommand
- fileBinaryReader
- fileTextReader
- delay
- getSDPath
- getSetting
- getTextByBaiduCloudOnAndroid
- setVolumes(type,volume)
- shift(type)
- sendMessage(phone,message)
完整示例
上面的章节已经对 MTE 进行了细节上的描述。为了让客户有更加直观、全面的认识,我们准备了一个完整示例。如果您是第一次接触 MTE,那么可以根据下面的步骤,切实体会一下如何通过 MTE,实现在不同手机上,启动不同的 APP。在下面这个示例中,我们准备了两台手机,通过 MTE,我们将在一台手机上启动微信,在另一台手机上启动 QQ。
配置文件 <mte.tpf>
首先,您必须准备一个配置文件 <mte.tpf>,内容如下:
Testname weixin deviceSN:'CUIVAEPR99999999' appname:'com.tencent.mm' username:'14016031' password:'password001' End Testname qq deviceSN:'KVSGFELFE6AY7LYL' appname:'com.tencent.mobileqq' username:'45178763' password:'password002' End
mte.tpf应该与您将要执行的脚本放在同一路径下。在此例中,我们将脚本文件和配置文件都置于<我的文档>/Scripts中。
MTE要调用的脚本
准备如下一个脚本 <mtesample.js>,实现启动不同 APP 的具体操作:
define("requireVersion","1.5.0.2865"); define("version","6.5.0.2886"); define("verbose",0); define("resolution","1080*1920"); print ("RUN TEST BEGIN ..."); print("Device SN is: " + Testrun.getContext().get('deviceSN')); print("APP to be started: " + Testrun.getContext().get('appname')); print("Username is: " + Testrun.getContext().get('username')); print("Password is: " + Testrun.getContext().get('password')); var device = Device.searchObject(sigmaConst.DevSerial, Testrun.getContext().get('deviceSN')); if(!device) { print(lastError()); } else { device.runApp(Testrun.getContext().get('appname')); }
这个脚本实现了简单的功能:根据启动参数,在对应的手机上启动对应的 APP。
调用 MTE 的语句
上面已经定义了 MTE 配置文件和调用脚本,要想让脚本切实运行起来,还需执行下面的语句:
testrunObj = new Testrun('Hello', 'mte.tpf', 'mtesample.js', 'weixin');
非常简单。在上面的语句中,’Hello’为要启动任务的任务名称,该名称用户可以自行定义。‘mte.tpf’为配置文件,’mtesample.js’为被调用脚本,’weixin’指定了要使用配置文件中的哪一个具体配置。
在执行上面这条语句之后,您会发现,在 weixin 对应配置所指定的手机上,已运行起了微信 APP。
对应的,如果您执行语句:
testrunObj = new Testrun('Hello2', 'mte.tpf', 'mtesample.js', 'qq');
那么,会在qq配置指定的手机上,启动 QQ App。
Testrun 仅仅只是 MTE 最基本的功能,runCTest 和 runDTest 显示出更加强大的能力。在对应的章节中,均有完整的说明示例。