uiautomator/Android Test Python example

19 篇文章 0 订阅

Note:

1.Linux/Python/uiautomator  will automatically install apk/stub named uiautomator/1.0 and  com.github.uiautomator.test (Test on Android7.1.2)

 

 Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program Name
tcp        0      0 :::9008                 :::*                    LISTEN      10835/com.github.uia

 

2.Windows/Python/uiautomator  will automatically install apk/stub named Test-api (Test on Android7.1.2)

3.Linux/AnroidSDK/tool/uiautomator  does not install any apk/stub (Test on Android7.1.2) but Android system default has /system/bin/uiautomator 

rk3399_firefly_box:/ $ which  uiautomator                                                                                            
/system/bin/uiautomator
rk3399_firefly_box:/ $ 
 

Python script example:

>>> from uiautomator import device

>>> from uiautomator import device as d

>>> d.info 

{u'displayRotation': 0, u'displaySizeDpY': 811, u'displaySizeDpX': 1442, u'screenOn': True, u'displayWidth': 1920, u'productName': u'rk3399_firefly_box', u'currentPackageName': u'com.android.music', u'sdkInt': 25, u'displayHeight': 1016, u'naturalOrientation': True}
>>> d.screen.off()
>>> d.screen.on()
>>> 
### Screen orientation 

>>> d.orientation = "l"   ### left 
>>> d.orientation = "r" 
>>> d.orientation = "n"  ### nature 

 

##################  Click any icon on the screen which has the icon/app named "L5"

>>> d(text="L5").click()
True
>>> 

>>> d(text="L5").info
{u'contentDescription': u'L5', u'checked': False, u'clickable': True, u'scrollable': False, u'text': u'L5', u'packageName': u'com.android.launcher3', u'selected': False, u'enabled': True, u'bounds': {u'top': 469, u'left': 328, u'right': 644, u'bottom': 631}, u'className': u'android.widget.TextView', u'focusable': True, u'focused': False, u'checkable': False, u'resourceName': u'com.android.launcher3:id/icon', u'longClickable': True, u'visibleBounds': {u'top': 469, u'left': 328, u'right': 644, u'bottom': 631}, u'childCount': 0}
>>> 
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值