当前位置:网站首页>Uiautomator2 common commands
Uiautomator2 common commands
2022-07-25 07:43:00 【A gorgeous cat】
From the original :https://github.com/openatx/uiautomator2/blob/master/QUICK_REFERENCE.md
import uiautomator2 as u2
d = u2.connect(“–serial-here–”) # Only one device can also omit parameters
d = u2.connect() # When a device
d = u2.connect(“10.1.2.3”) # Through the equipment IP Connect ( Need to be on the same LAN and on the device atx-agent Installed and started )
d.app_current() # Get foreground application packageName, activity
d.app_start(“com.example.app”) # Start the application
d.app_start(“com.example.app”, stop=True) # Stop the application before starting it
d.app_stop(“com.example.app”) # Stop applying
app = d.session(“com.example.app”) # Start the app and get session
session The purpose of is to monitor whether the application flashes back while operating , Operate when flashing back , Will throw out SessionBrokenError
app.click(10, 20) # Coordinate click
nothing session Operate in state
message_a=d.toast.get_message() # obtain toast
d.click(10, 20) # Coordinate click
d.swipe(10, 20, 80, 90) # from (10, 20) Slide to (80, 90)
d.swipe_ext(“right”) # Slide the entire screen to the right
d.swipe_ext(“right”, scale=0.9) # Slide the screen right , The sliding distance is... Of the screen width 90%
d.press(“back”) # Simulate clicking the back button
d.press(“home”) # simulation Home key
d.send_keys(“hello world”) # Analog input , Only when the cursor is already in the input box can
d.clear_text() # Clear the input box
perform shell command
output, exit_code = d.shell(“ps -A”, timeout=60) # perform shell command , Get output and exitCode
output = d.shell(“pwd”).output # That's ok
exit_code = d.shell(“pwd”).exit_code # That's ok
Element operation
d.xpath(“ Open an account now ”).wait() # Waiting elements , Longest etc 10s( Default )
d.xpath(“ Open an account now ”).wait(timeout=10) # Modify the default wait time
Common configuration
d.settings[‘wait_timeout’] = 20 # Control to find the default wait time ( Default 20s)
xpath operation
d.xpath(“ Open an account now ”).click() # Including find wait + Click on the action , matching text perhaps description Equal to the button to open an account immediately
d.xpath(“//*[@text=‘ private FM’]/…/android.widget.ImageView”).click()
d.xpath(‘//*[@text=“ private FM”]’).get().info # Get control information
for el in d.xpath(‘//android.widget.EditText’).all():
print(“rect:”, el.rect) # output tuple: (left_x, top_y, width, height)
print(“bounds:”, el.bounds) # output tuple: (left, top, right, bottom)
print(“center:”, el.center())
el.click() # click operation
print(el.elem) # Output lxml Resolved Node
Monitoring pop-up window ( Monitor in the thread )
d.watcher.when(“ skip ”).click()
d.watcher.start()
边栏推荐
- How does uxdb extract hours, minutes and seconds from date values?
- The value of integer a after bitwise negation (~) is - (a+1)
- Polling, interrupt, DMA and channel
- How to reverse a stack with recursive functions and stack operations only
- 【Unity入门计划】基本概念-触发器 Trigger
- What has become a difficult problem for most people to change careers, so why do many people study software testing?
- [unity introduction program] basic concepts -2d rigid body 2D
- Analysis of difficulties in diagramscene project
- 【论文笔记】Progressive Layered Extraction (PLE): A Novel Multi-Task Learning (MTL) Model for Personalized
- MathWorks has been in China for 15 years. What are the secrets of continuous innovation?
猜你喜欢

What has become a difficult problem for most people to change careers, so why do many people study software testing?

Teach you to use cann to convert photos into cartoon style

IoT物联网嵌入式设备中30种常见传感器模块简介及原理讲解

QT学习日记20——飞机大战项目

app耗电量测试

全新8.6版本SEO快排系统(可源码级搭建)

钉钉最新版,怎么清除登录手机号历史记录数据

MATLAB自编程系列(1)---角分布函数

Leetcode (Sword finger offer) - 04. search in two-dimensional array
![[unity entry program] make my first little game](/img/e7/5dcb113c7fabd73ed632fb29619369.png)
[unity entry program] make my first little game
随机推荐
[paper notes] progressive layered extraction (PLE): a novel multi task learning (MTL) model for personalized
【软件测试】包装简历从这几点出发、提升通过率
Native form submission data
How to do a good job in safety development?
[programmer 2 Civil Servant] summary of some common problems about system research
[dynamic programming] - Knapsack model
[recommended reading] a collection of super useful vulnerability scanning tools!
【论文笔记】EFFICIENT CNN ARCHITECTURE DESIGN GUIDED BY VISUALIZATION
深度学习制作数据集时,从长视频中指定每隔多少帧提取一张图像到指定文件路径的方法
QT learning diary 20 - aircraft war project
Problems during nanodet training: modulenotfounderror: no module named 'nanodet' solution
If Debian infringes the rust trademark, will it be exempted by compromising and renaming?
Hikaricp connection pool does not operate for a period of time, and the data is automatically disconnected
Nailing the latest version, how to clear the login phone number history data
Robot framework mobile terminal Automation Test ----- 01 environment installation
【Unity入门计划】基本概念-GameObject&Components
【程序员2公务员】一、基本认知
uiautomator2 常用命令
Gather the wisdom of developers and consolidate the foundation of the database industry
[paper notes] effective CNN architecture design guided by visualization