STF 安装
https://github.com/openstf/stf
#如果已经安装可以使用brew upgrade进行升级
brew install rethinkdb graphicsmagick zeromq protobuf yasm pkg-config
#了解下自己的node版本和npm的版本
npm version
#解决好***问题,搞不定就用cnpm,安装之前先卸载为佳,因为npm bug挺多,会误判一些lib
#npm uninstall -g stf
#rm -rf /usr/local/lib/node_modules/stf/
npm install -g stf
常见的坑
- node 版本太新,最好使用 LTS 版本
- 依赖库安装时候出现了中断导致了各种不兼容
- 文件权限问题,用户、组的权限设置不对
api
https://github.com/openstf/stf/blob/master/doc/API.md
key=xxxxxxx
curl -H "Authorization: Bearer $key" http://127.0.0.1:7100/api/v1/user | jq
key=368d6df9a82147d29a7a15f94b3d1495af2a6e857a654933bdda686f5e1ef5bf
device=emulator-5554
#获得设备列表:
curl -H "Authorization: Bearer $key" http://localhost:7100/api/v1/devices | jq .devices[].serial
申请设备:
curl -X POST --header "Content-Type: application/json" --data '{"serial":"$device"}' -H "Authorization: Bearer $key" http://127.0.0.1:7100/api/v1/user/devices
远程调试:
curl -X POST -H "Authorization: Bearer $key" http://127.0.0.1:7100/api/v1/user/devices/$device/remoteConnect
释放设备:
curl -X DELETE -H "Authorization: Bearer $key" http://127.0.0.1:7100/api/v1/user/devices/$device