#!/bin/bash
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
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()
{
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
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
"'| awk -F '[\\\\[|\\\\]]|,' '{print ($2+$5)/2,($3+$6)/2}'`
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 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 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
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
}
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
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
`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}'`
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
}
q=1
while [ $q -le 10000 ]
do
test_sbk
sleep 5
test_shexiang
test_leftxiang
test_rightxiang
test_wenzhengcaiji
test_baogo
sleep 5
test_back
let q++
done