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的主要内容,如果未能解决你的问题,请参考以下文章

使用appium在android7.0真机上测试程序时报错command failed shell “ps ‘uiautomator’”的解决方式

appium在android 7.0真机上运行报错command failed shell:............ps:'uiautomator"的解决方式

使用uiautomator2实现对手机app的操作(windows)

adb命令行执行uiautomator2

小知识分享:adb uiautomator 命令 dump ui 树信息

小知识分享:adb uiautomator 命令 dump ui 树信息