系列介绍
QAUi 系列阅读指南
Appium Desktop 版查看控件
- 进入高级配置,建议如上配置,然后 Save As Preset 保存为一个配置表,下次好用
- 点击 Edit Configurations 查看 Android sdk 和 JDK 是否配置正确
- 进入 Preset,点击上一步中的配置表,然后点击 Start Server V1.9.1
{
"deviceName": "396f68f07d94",
"automationName": "uiautomator2",
"platformName": "Android",
"noReset": true,
"autoLaunch": false,
"appPackage": "xxx.x.x.xx",
"appActivity": "x.x.x.x.Activity",
"unicodeKeyboard": false,
"resetKeyboard": true,
"noSign": true,
"platformVersion": "7.1.2"
}
{
"deviceName": "iphone8plus",
"platformVersion": "11.2.5",
"udid": "c65d00a8cda9947953dac52e92071aa1481f23a2",
"automationName": "XCUITest",
"noReset": false,
"platformName": "iOS",
"bundleId": "xx.xxx.xx.x",
"autoLaunch": false
}
- 点击服务器运行界面右上方的放大镜按钮进入该空间查看界面
- 配置初始化参数,之后点击保存为一个配置表,然后点击开始 Session
- 点击 start session 之后,就进入到了 XML 查看界面!
android 控件体系
//唯一标识
Find By Selector
id com.benqu.wuta:id/home_camera_view
xpath /hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ImageView
//属性
Attribute Value
NAF true
index 0
text 相机
class android.widget.ImageView
package com.benqu.wuta
content-desc 进入相机
checkable false
checked false
clickable true
enabled true
focusable false
focused false
scrollable false
long-clickable false
password false
selected false
bounds [245,1071][475,1301]
resource-id com.benqu.wuta:id/home_camera_view
instance 8
- Find By 下面显示的属性为该页面唯一的标识,可以用这些属性找到你选择的元素
- Attribute Value 则为该控件的属性
- 如果当前界面有相同的你查找的标识,appium 将默认选择第一个
resource-id
WebElement webElement=driver.findElementById("com.benqu.wuta:id/home_camera_view");
text (UIAutomator1 查找体系)
WebElement webElement=driver.findElementByAndroidUIAutomator("new UiSelector().text(\"相机\")");
content-desc
WebElement webElement=driver.findElementByAccessibilityId("进入相机");
class
WebElement webElement=driver.findElementByClassName("android.widget.ImageView");
XPath
WebElement webElement=driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ImageView");
iOS 控件体系
Find By Selector
accessibility id 企业微信
xpath //XCUIElementTypeIcon[@name="企业微信"]
Attribute Value
type XCUIElementTypeIcon
name 企业微信
label 企业微信
enabled true
visible true
x 199
y 378
width 64
height 86
name
WebElement webElement=driver.findElementByAccessibilityId("企业微信");
xpath
WebElement webElement=driver.findElementByXPath("//XCUIElementTypeIcon[@name=/"企业微信/"]");
NsPredicate (ios xcuitest-driver 查找体系)
- (IN)|(BETWEEN)|(CONTAINS)|(BEGINSWITH)|(ENDSWITH)|(LIKE)|(MATCHES)|(AND)|(OR)
java
WebElement webElement=driver.findElementByIosNsPredicate("label == '企业微信'");