Mac安装stf

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
}

转载于:https://www.cnblogs.com/an5456/p/11531153.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值