fix: load testcase panic caused by config options

This commit is contained in:
lilong.129
2025-04-27 11:50:50 +08:00
parent 5385556b66
commit d2976844fc
7 changed files with 134 additions and 222 deletions

View File

@@ -1,6 +1,6 @@
{
"config": {
"name": "播_抖极_feed卡片_android",
"name": "播_抖音_滑动场景_随机间隔_android",
"variables": {
"device": "${ENV(SerialNumber)}"
},
@@ -8,91 +8,32 @@
{
"serial": "$device",
"log_on": true,
"close_popup": true
"adb_server_host": "localhost",
"adb_server_port": 5037,
"uia2_ip": "localhost",
"uia2_port": 6790,
"uia2_server_package_name": "io.appium.uiautomator2.server",
"uia2_server_test_package_name": "io.appium.uiautomator2.server.test"
}
]
},
"teststeps": [
{
"name": "清理android无关进程",
"name": "启动抖音",
"android": {
"os_type": "android",
"actions": [
{
"method": "app_terminate",
"params": "com.ss.android.ugc.aweme"
},
{
"method": "app_terminate",
"params": "com.ss.android.ugc.aweme.lite"
},
{
"method": "app_terminate",
"params": "com.smile.gifmaker"
},
{
"method": "app_terminate",
"params": "com.kuaishou.nebula"
},
{
"method": "app_terminate",
"params": "com.tencent.mm"
},
{
"method": "app_terminate",
"params": "com.duowan.kiwi"
},
{
"method": "app_terminate",
"params": "air.tv.douyu.android"
},
{
"method": "app_terminate",
"params": "com.xingin.xhs"
},
{
"method": "app_terminate",
"params": "com.taobao.taobao"
},
{
"method": "app_terminate",
"params": "tv.danmaku.bili"
},
{
"method": "app_terminate",
"params": "com.cmcc.cmvideo"
},
{
"method": "app_terminate",
"params": "com.xunmeng.pinduoduo"
},
{
"method": "app_terminate",
"params": "com.cctv.yangshipin.app.androidp"
}
]
}
},
{
"name": "启动抖音极速版",
"android": {
"actions": [
{
"method": "app_terminate",
"params": "com.ss.android.ugc.aweme.lite"
},
{
"method": "app_launch",
"params": "com.ss.android.ugc.aweme.lite"
"params": "com.ss.android.ugc.aweme"
},
{
"method": "sleep",
"params": 10
},
{
"method": "close_popups",
"options": {
"max_retry_times": 2
}
}
]
},
@@ -100,139 +41,119 @@
{
"check": "ui_foreground_app",
"assert": "equal",
"expect": "com.ss.android.ugc.aweme.lite",
"msg": "app [com.ss.android.ugc.aweme.lite] should be in foreground"
"expect": "com.ss.android.ugc.aweme",
"msg": "app [com.ss.android.ugc.aweme] should be in foreground"
}
]
},
{
"name": "处理通讯录弹窗",
"android": {
"actions": [
{
"method": "tap_ocr",
"params": "拒绝",
"ignore_NotFoundError": true
}
]
}
},
{
"name": "处理青少年弹窗",
"android": {
"os_type": "android",
"actions": [
{
"method": "sleep",
"params": 5
},
{
"method": "tap_ocr",
"params": "我知道了",
"ignore_NotFoundError": true
"options": {
"max_retry_times": 1,
"ignore_NotFoundError": true
}
}
]
}
},
{
"name": "点击直播标签,进入直播间",
"android": {
"actions": [
{
"method": "swipe_to_tap_texts",
"params": [
"看直播开宝箱",
"最高领",
"点击进入直播间"
],
"identifier": "click_live_new",
"max_retry_times": 40,
"wait_time": 2,
"direction": [
0.5,
0.8,
0.5,
0.2
],
"scope": [
0.1,
0.5,
0.9,
0.9
],
"offset": [
0,
-100
]
}
]
}
},
{
"name": "等待30s",
"android": {
"actions": [
{
"method": "sleep",
"params": 30
}
]
}
},
{
"name": "下滑进入下一个直播间",
"name": "滑动 Feed 3 次,随机间隔 0-5s",
"loops": 3,
"android": {
"os_type": "android",
"actions": [
{
"method": "swipe",
"params": [
0.5,
0.7,
0.5,
0.1
],
"identifier": "slide_in_live_new"
"params": "up",
"options": {
"max_retry_times": 1
}
},
{
"method": "sleep",
"params": 30
"method": "sleep_random",
"params": [
0,
5
]
}
]
}
},
{
"name": "返回主界面,并打开本地时间戳",
"name": "滑动 Feed 1 次,随机间隔 5-10s",
"loops": 1,
"android": {
"os_type": "android",
"actions": [
{
"method": "swipe",
"params": "up",
"options": {
"max_retry_times": 1
}
},
{
"method": "sleep_random",
"params": [
5,
10
]
}
]
}
},
{
"name": "滑动 Feed 10 次70% 随机间隔 0-5s30% 随机间隔 5-10s",
"loops": 10,
"android": {
"os_type": "android",
"actions": [
{
"method": "swipe",
"params": "up",
"options": {
"max_retry_times": 1
}
},
{
"method": "sleep_random",
"params": [
0,
5,
0.7,
5,
10,
0.3
]
}
]
}
},
{
"name": "exit",
"android": {
"os_type": "android",
"actions": [
{
"method": "app_terminate",
"params": "com.ss.android.ugc.aweme.lite"
},
{
"method": "home"
},
{
"method": "swipe_to_tap_app",
"params": "local",
"max_retry_times": 5,
"offset": [
0,
-50
]
},
{
"method": "sleep",
"params": 10
"params": "com.ss.android.ugc.aweme"
}
]
},
"validate": [
{
"check": "ui_ocr",
"assert": "exists",
"expect": "17",
"msg": "打开本地时间戳失败"
"check": "ui_foreground_app",
"assert": "not_equal",
"expect": "com.ss.android.ugc.aweme",
"msg": "app [com.ss.android.ugc.aweme] should not be in foreground"
}
]
}
]
}
}

View File

@@ -15,7 +15,8 @@ func TestAndroidDouyinFeedTest(t *testing.T) {
WithVariables(map[string]interface{}{
"device": "${ENV(SerialNumber)}",
}).
SetAndroid(option.WithSerialNumber("$device")),
SetAndroid(option.WithSerialNumber("$device"),
option.WithAdbLogOn(true)),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").
Android().