APP automation editor tool

Due to a lot of things going on recently, I haven’t updated the article for a long time. When you are doing APP automated testing, you may be using the inspect officially provided by Appium to locate elements, but this tool is inconvenient for debugging, so today I will share with you a more useful APP element positioning tool: weeditor

Weeditor is based on web page debugging, no need to download the application package, and it is very convenient to use.

(1) Introduction to editor

Weditor is a python-based tool for viewing APP elements. It can provide functions such as assisting in writing scripts, locating elements, and debugging codes. Compared with inspect provided by appium , it is more flexible and convenient to use and easy to debug.

(2) How to use

  1. Install editor

pip install --pre weditor

2. Start editor

python -m weditor

3. Connect the device

Detect whether the device is connected through the adb command: adb devices

4. Install atx-agent on the device

# 安装命令
python -m uiautomator2 init

5.weditor connects to mobile phone

Note: When editor is started, the browser will automatically open and enter the page as shown below.

After the mobile phone is successfully connected, a screenshot of the connected device will be automatically obtained to view the corresponding elements.

picture

(3) How to capture page elements

element positioning

The method of positioning elements supports the positioning method of uiautomator, and can also support xpath and coordinate positioning:

· 1. You can view the resourceId attribute of the element

· 2. Automatically generate xpath positioning method

· 3. Support coordinate click, according to the screen ratio

· 4. Automatically generate uiautomator positioning method reference code

· 5. You can check to force the use of xpath

picture

coding online debugging

1. Import the uiautomator2 library and connect the current device

import uiautomator2 as u2

# 连接并启动
d = u2.connect() 

# 打印当前链接设备信息
print(d.info)

# 控制台输入结果
{'currentPackageName': 'com.addcn.android.house591', 'displayHeight': 2186

2. Use the positioning element method in uiautomator2

# 2.定位元素输入框,使用属性定位
# uiautomator2定位方式:d(定位方式=定位值)

d(description="請輸入社區/街道名稱搜尋").click()

# 3.在输入框输入内容,并点击提交
d(text="請輸入社區/街道名稱搜尋").send_keys('测试')

# 清除输入框内容
d.clear_text()

# 点击回车键
d.press('enter')

3. Use the xpath positioning method in uiautomator2

# 1. 定位元素点击元素,使用xpath定位
d.xpath('//*[@text="中古屋"]').click()

Since the editor positioning tool is based on the uiautomator2 framework, the attributes, XPath and other methods of some elements are also applicable to the Appium framework, and are more friendly and can be debugged immediately, which can greatly save time in debugging scripts.

Finally, I would like to thank everyone who reads my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, if you can use it, you can take it directly:

Insert image description here

This information should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can also help you! 

Guess you like

Origin blog.csdn.net/2301_78276982/article/details/132902321