【无标题】

#!/bin/bash
#uiautomator获取页面元素,元素是否在该页,判断进行点击事件测试
#mkdir ip132
#adb -s $ip134 shell am start -n com.guoming.health.device.voiceskill/com.guoming.health.device.voiceskill.video.ui.ConstactsHomeActivity
ip=6LSOHA49SOLR8LMN
date "+%m-%d_%H-%M-%S"
fail_count=0
pass_count=0
function test_sbk()
{
##社保卡和就诊卡模式
    echo "中医体质辨识首页,识别就诊卡和社保卡"
	sleep 5
	adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	if adb -s $ip shell cat /data/local/tmp/app.uix |grep '读取卡号' > /dev/null
	then
		bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="读取卡号"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
		echo $bounds
		#输入社保卡号或者就诊卡
		adb -s $ip shell input text 12345678
		#点击回车键,读取信息
		adb -s $ip shell input keyevent 66
		sleep 3
	    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix

	    if adb -s $ip shell cat /data/local/tmp/app.uix |grep '诊前检查' > /dev/null
	    then
	        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="开始检测"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
	        echo $bounds
	        adb -s $ip shell input tap $bounds
	        #echo "诊前检查成功"&&date "+%m-%d_%H-%M-%S" >>log
	    else
	    #进入到个人信息确认页
            echo "诊前检查失败"&&date "+%m-%d_%H-%M-%S"
	    fi
	else
        echo "读取卡号失败"&&date "+%m-%d_%H-%M-%S"
	fi
}
function test_jj()
{
##社保卡和就诊卡模式
    echo "中医体质辨识首页,极简模式"
	sleep 5
	adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	if adb -s $ip shell cat /data/local/tmp/app.uix |grep '中医舌脉检查' > /dev/null
	then
		bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/btn_start'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
		echo $bounds
		#输入社保卡号或者就诊卡
		adb -s $ip shell input tap $bounds
	fi
}
function test_shexiang()
{
#回到初始位置技能页面,导航栏存在重复text,找到坐标点进行点击
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    sync
	sleep 3
	if adb -s $ip shell cat /data/local/tmp/app.uix |grep '舌象采集' > /dev/null
	then
        echo "舌象采集"
        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="舌象采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
        #点击技能
        adb -s $ip shell input tap $bounds
        sleep 15
        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        #出现中医体质测试,说明舌象仪页面,没有拍摄成功
        if adb -s $ip shell cat /data/local/tmp/app.uix |grep '中医体质测试' > /dev/null
        then
            adb -s $ip shell input tap 94 55
            #退出舌象检测,开始面诊测试
            test_mianxiang
	    else
	        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="确认采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
	        adb -s $ip shell input tap $bounds
	        sleep 15
        fi
	else
	#点击返回date "+%m-%d_%H-%M-%S"
	    echo "舌象测试失败"&&date "+%m-%d_%H-%M-%S" >>log
	    adb -s $ip shell input tap 94 55
	fi
}
function test_mianxiang() {
#点击面象采集
    sleep 3
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="面象采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
    echo $bounds
	adb -s $ip shell input tap $bounds
    echo "点击面象采集"
    sleep 5
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '开始采集' > /dev/null
    then
        echo "点击确认采集"
	    bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="开始采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
	    echo $bounds
	    adb -s $ip shell input tap $bounds
	    sleep 30
	    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	    if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '确认提交' > /dev/null
	    then
	        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="确认提交"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
	        echo $bounds
	        adb -s $ip shell input tap $bounds
	        sleep 30
	        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	        if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '温馨提示' > /dev/null
	        then
	            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="确认重试"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
	            echo $bounds
	            adb -s $ip shell input tap $bounds
	            sleep 5
	            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="返回"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
	            adb -s $ip shell input tap $bounds
	        fi
        fi

	else
	    echo "面象测试失败" >>log
	    date "+%m-%d_%H-%M-%S" >>log
	    test_back

	fi
}
#脉象检测质进入确认识别到脉象仪

function test_leftxiang() {

    sleep 5
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '左手脉象' > /dev/null
    then
        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="左手脉象"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`

        adb -s $ip shell input tap $bounds
        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai "脉象仪断开连接" >/dev/null
        then
            mkdir leftxiang
            cd leftxiang
            adb -s $ip pull /sdcard/mtklog
            adb -s $ip shell screencap -p /sdcard/$q.png&&adb -s $ip pull /sdcard/$q.png
            cd ..
            #点击返回键
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/include_tv_back"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
        else
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="开始采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            #点击返回,关闭遮罩
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/iv_back"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
            #点击重新检测回到上页面
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="重新检测"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
            #点击返回回到四诊页面
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="返回"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
        fi
    fi


}
function test_rightxiang() {

    sleep 5
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '右手脉象' > /dev/null
    then
        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="右手脉象"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`

        adb -s $ip shell input tap $bounds
        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai "脉象仪断开连接" >/dev/null
        then
            mkdir rightxiang
            cd rightxiang
            adb -s $ip pull /sdcard/mtklog
            adb -s $ip shell screencap -p /sdcard/$q.png&&adb -s $ip pull /sdcard/$q.png
            cd ..
            #点击返回键
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/include_tv_back"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
        else
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="开始采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            #点击返回,关闭遮罩
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/iv_back"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
            #点击重新检测回到上页面
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="重新检测"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
            #点击返回回到四诊页面
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/include_tv_back"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
        fi
    fi


}

function test_wenzhengcaiji() {
#点击问诊采集
sleep 5
adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
#bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="没有"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
#echo $bounds
if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '问诊采集' > /dev/null
then
	bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="问诊采集"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
    echo $bounds
    adb -s $ip shell input tap $bounds
    sleep 5
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '继续填写' > /dev/null
    then
        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="继续填写"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
        sleep 5
        adb -s $ip shell input tap $bounds
        sleep 2
        #adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        #bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="下一项"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
        #sleep 3
        #adb -s $ip shell input tap $bounds
        sleep 3
        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        sleep 3
        if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '提交' > /dev/null
        then
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="提交"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            sleep 5
            adb -s $ip shell input tap $bounds
            sleep 5
            s=1
            while [ $s -le 10 ]
	        do
		        sleep 1
		        adb -s $ip shell input tap 126 208
		        let s++
		    done
		    k=1
		    while [ $k -le 28 ]
		    do
		            adb -s $ip shell input tap 126 208
		            let k++
		    done

	    #点击第30题选项
	        adb -s $ip shell input tap 126 261
            sleep 5
            adb -s $ip shell input tap 126 261
            adb -s $ip shell input tap 126 461
        #点击提交,问卷
	        adb -s $ip shell input tap 827 528

	        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	        sleep 3
	        if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '温馨提示' > /dev/null
	        then
	            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="确认提交"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
                echo $bounds
                adb -s $ip shell input tap $bounds
            else
                #没有出现弹窗说明,没有点击提交
                bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="返回"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
                adb -s $ip shell input tap $bounds
                echo "没有点击提交" >>log
                date "+%m-%d_%H-%M-%S" >>log
            fi
        fi
    fi
fi
#调用test_zhongyitizhi确认是否回到中医四诊
    #test_zhongyitizhi
}
function test_baogo() {
#点击打印报告
    sleep 60s
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '打印报告' > /dev/null
    then
        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="打印报告"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
        echo $bounds
        adb -s $ip shell input tap $bounds
        echo "打印报告"
        sleep 100s
        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="打印报告"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
        adb -s $ip shell input tap $bounds
        sleep 60s
        adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
        #出现异常弹窗,点击”我知道了“关闭弹窗
        if adb -s $ip shell cat /data/local/tmp/app.uix |grep -ai '我知道了' > /dev/null
        then
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="我知道了"' | awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell screencap -p /sdcard/$q.png&&adb -s $ip pull /sdcard/$q.png
            adb -s $ip shell cd sdcard/&&adb -s $ip shell rm -rf /sdcard/*.png
            adb -s $ip shell cd ..
            adb -s $ip shell input tap $bounds
            echo ============点击x,回到四诊页面============
            adb pull /sdcard/mtklog
            #date "+%m-%d_%H-%M-%S" >>log
            adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
            bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/iv_close"' | awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            adb -s $ip shell input tap $bounds
        else
    #打印机没有异常时,走else路径
            #bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/iv_close"' | awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
            #adb -s $ip shell input tap $bounds
            echo "打印机打印成功"
        fi
    else

        test_back
    fi
}

function test_back() {
#点击打印报告
    sleep 5
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
	bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'resource-id="com.guoming.health.device.hospital:id/include_tv_back"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
    echo $bounds
    echo "点击退出"
	adb -s $ip shell input tap $bounds
    adb -s $ip shell uiautomator dump /data/local/tmp/app.uix
    sleep 5
    bounds=`adb -s $ip shell cat /data/local/tmp/app.uix | sed 's#<node #^<node #g' |tr '^' '\n'| grep 'text="确认"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
    echo $bounds
    echo "点击确认"
	adb -s $ip shell input tap $bounds
    #点击全部选项
	#调用test_zhongyitizhi确认是否回到中医四诊
    #test_zhongyitizhi
}

q=1
while [ $q -le 10000 ]
do
    #test_jj
    test_sbk
    sleep 5
    test_shexiang
    #adb -s $ip shell screencap -p /sdcard/$q.png&&adb -s $ip pull /sdcard/$q.png
    test_leftxiang
    test_rightxiang
    #test_mianxiang
    test_wenzhengcaiji
    test_baogo
    sleep 5
    test_back
    let q++
done




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值