adb uiautomator + shell

Posted 头鹰在学习

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了adb uiautomator + shell相关的知识,希望对你有一定的参考价值。

adb 将当前页面的数据导出来

adb shell "uiautomator dump --compressed && cat /sdcard/window_dump.xml"

  

 shell读取坐标

cat /temp/ui.xml |sed ‘s#<node #^<node #g‘ | tr ^ ‘
‘ |grep ‘"确定“‘ | awk -E -F ‘\[|\]|,‘ ‘{print $(NF-1)}‘

  

sed插入^

tr替换

grep抓取行

awk 分隔[],的数据并读取

 

点击

adb shell input tap $( cat xxxxxxxx |sed xxxxx|grep xxxxx|awk xxxxx)

 

封装一下,把确定换成 $@

click(){
adb shell xxxxxxx
}

  

调用

click ‘"确定"‘

  

 

输入

send_key{
  adb shell input text $@  
}

  

获取手机屏幕大小

adb shell wm size 

  

 

以上是关于adb uiautomator + shell的主要内容,如果未能解决你的问题,请参考以下文章