1.brew install rethinkdb graphicsmagick zeromq protobuf yasm pkg-config
2.node版本8.x我的是8.15.0
3.npm install -g stf 或者cnpm install -g stf
4.后天启动数据库:nohup rethinkdb &
5.启动STF的客户端:stf local --public-ip 本机IP --allow-remote
例如:stf local --public-ip 192.168.1.102 --allow-remote
在浏览器访问:http://192.168.0.101:7100/
6.常用的接口脚本
#!/usr/bin/env bash STF_TOKEN=4df3f1f8232d459aa83a4ffb15ed1d44695868e40fc7462892adc5ea0ac19d63 #STF_URL=http://39.105.132.200:7100 STF_URL=http://127.0.0.1:7100 DEVICE_SERIAL="emulator-5554" # 申请设备 function add_device() { response=$(curl -X POST -H "Content-Type: application/json" \ -H "Authorization: Bearer $STF_TOKEN" \ --data "{\"serial\": \"$DEVICE_SERIAL\"}" $STF_URL/api/v1/user/devices) success=$(echo "$response" | jq .success | tr -d '"') description=$(echo "$response" | jq .description | tr -d '"') if [ "$success" != "true" ]; then echo "Failed because $description" echo exit 1 fi echo "Device $DEVICE_SERIAL added successfully" } # 远程链接设备 function remote_connect() { response=$(curl -X POST \ -H "Authorization: Bearer $STF_TOKEN" \ $STF_URL/api/v1/user/devices/$DEVICE_SERIAL/remoteConnect) success=$(echo "$response" | jq .success | tr -d '"') description=$(echo "$response" | jq .description | tr -d '"') if [ "$success" != "true" ]; then echo "Failed because $description" echo exit 1 fi remote_connect_url=$(echo "$response" | jq .remoteConnectUrl | tr -d '"') echo $remote_connect_url adb connect $remote_connect_url echo "Device $DEVICE_SERIAL remote connected successfully" } # 移除设备 function remove_device() { # 断开设备链接 adb disconnect $remote_connect_url response=$(curl -X DELETE \ -H "Authorization: Bearer $STF_TOKEN" \ $STF_URL/api/v1/user/devices/$DEVICE_SERIAL) success=$(echo "$response" | jq .success | tr -d '"') description=$(echo "$response" | jq .description | tr -d '"') if [ "$success" != "true" ]; then echo "Failed because $description" echo exit 1 fi echo "Device $DEVICE_SERIAL removed successfully" } function run_device() { add_device remote_connect sleep 2 adb devices remote_device=$remote_connect_url java -jar /Users/anxiaodong/learn/appcrawler/appcrawler-2.4.0-jar-with-dependencies.jar \ -c /Users/anxiaodong/learn/appcrawler/xueqie.yml \ --capability "udid=${remote_device}, systemPort=1${remote_device#*:}, appPackage=com.xueqiu.android,appActivity=.view.WelcomeActivityAlias" remove_device } function every_device() { #获得可用设备列表 devices=$(curl -H "Authorization: Bearer $STF_TOKEN" $STF_URL/api/v1/devices | jq -r '.devices[] | select(.present==true)|.serial ') for DEVICE_SERIAL in $devices; do { add_device remote_connect sleep 2 remote_device=$remote_connect_url eval $1 adb disconnect $remote_device sleep 2 remove_device } & done }