MAC下STF的环境搭建

最近由于需要用到批量的远程真机调试,发现STF可以实现,网上各种资料也很多,但是比较分散,遂将相关过程及坑整理如下。

首先介绍下STF,全名Smartphone Test Farm---智能手机测试平台,可以提供远程真机调试的功能,目前仅支持Android设备,项目地址:https://openstf.github.io/,详细资料可以去github了解。

【环境搭建】

1. 安装node.js

brew install node

2. 安装Android-SDK和java

注意设置环境变量

3. 安装 rethinkdb

brew install rethinkdb

4. 安装 graphicsmagick

brew install graphicsmagick

5. 安装 zeromq

brew install zeromq

6. 安装protobuf

brew install protobuf

7. 安装pkg-config

brew install pkg-config

8. 安装yasm

brew install yasm

9. 安装bower

npm install bower -g

10.安装STF

npm install -g stf

11.全部装完之后检查环境配置

stf doctor(不报错即可,报错按照错误提示解决)

MAC下STF的环境搭建

【启动stf】

1. 启动rethinkDB

MAC下STF的环境搭建

2. 启动stf服务端

指定ip和允许远程连接启动:stf local --public-ip xx.xx.xx.xx --allow-remote

MAC下STF的环境搭建

3. 启动后的界面,浏览器输入对应地址http://192.168.76.103:7100,登录页面的用户名和邮箱随便输即可

MAC下STF的环境搭建


【相关坑】

1. 安装stf环节,一直死循环提示:

gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/stf/node_modules/zmq/.node-gyp/8.1.2"gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/stf/node_modules/zmq/.node-gyp"

解决办法:
(1)sudo chmod -R 777 /var/root
(2)如果上面1步骤仍然不行,可能是由于苹果SIP造成,可以按照如下进行操作:
1.重启 Mac,按住 Command+R 键直到 Apple logo 出现,进入 Recovery Mode
2.点击 Utilities > Terminal
3.在 Terminal 中输入 csrutil disable,之后回车
4.重启 Mac

2. stf doctor时提示:

Error: Could not locate the bindings file. Tried:→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/Debug/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/Release/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/out/Debug/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/Debug/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/out/Release/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/Release/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/default/zmq.node→ /usr/local/lib/node_modules/stf/node_modules/zmq/compiled/6.10.1/darwin/x64/zmq.nodeat bindings (/usr/local/lib/node_modules/stf/node_modules/bindings/bindings.js:88:9)at Object. (/usr/local/lib/node_modules/stf/node_modules/zmq/lib/index.js:6:30)

解决办法:
(1) 卸载stf,重新安装zeromq、stf

3.  之前安装的相关软件版本过低

解决办法:

(1) 根据提示更新软件版本


4. 连接手机时提示:

Setup had an error Error: Cannot find module '/usr/local/lib/node_modules/stf/node_modules/[email protected]@jpeg-turbo/lib/binding/node-v57-linux-x64/jpegturbo.node'

解决办法:

(1) 卸载stf,重新安装yasm、stf,这里一定要注意先后顺序,要不会失败