update: add kuaishou ui automation case

This commit is contained in:
xucong.053
2022-10-13 14:23:06 +08:00
parent 6ec187d995
commit 3aaa6708fe
3 changed files with 298 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
//go:build localtest
package uitest
import (
"testing"
"github.com/httprunner/httprunner/v4/hrp"
)
func TestIOSKuaiShouLive(t *testing.T) {
testCase := &hrp.TestCase{
Config: hrp.NewConfig("直播_快手_关注天窗_ios").
WithVariables(map[string]interface{}{
"device": "${ENV(UDID)}",
"ups": "大哥,王者",
}).
SetIOS(hrp.WithUDID("$device"), hrp.WithLogOn(true), hrp.WithWDAPort(8100), hrp.WithWDAMjpegPort(9100)),
TestSteps: []hrp.IStep{
hrp.NewStep("启动快手").
IOS().
AppTerminate("com.jiangjia.gif").
AppLaunch("com.jiangjia.gif").
Home().
SwipeToTapApp("快手", hrp.WithMaxRetryTimes(5)).Sleep(10).
Validate().
AssertOCRExists("精选", "进入快手失败"),
hrp.NewStep("点击首页").
IOS().
TapByOCR("首页", hrp.WithIndex(-1)).Sleep(10),
hrp.NewStep("点击发现页").
IOS().
TapByOCR("发现", hrp.WithIndex(1)).Sleep(10),
hrp.NewStep("点击关注页").
IOS().
TapByOCR("关注", hrp.WithIndex(1)).Sleep(10),
hrp.NewStep("点击直播标签,进入直播间").
IOS().
SwipeToTapTexts([]string{}, hrp.WithFunction("${split_by_comma($ups)}"), hrp.WithCustomDirection(0.6, 0.2, 0.2, 0.2), hrp.WithIdentifier("click_live")).Sleep(60).
Validate().
AssertOCRExists("说点什么", "进入直播间失败"),
hrp.NewStep("下滑进入下一个直播间").
IOS().
Swipe(0.9, 0.7, 0.9, 0.3, hrp.WithIdentifier("slide_in_live")).Sleep(60),
},
}
if err := testCase.Dump2JSON("ios_kuaishou_follow_live_test.json"); err != nil {
t.Fatal(err)
}
if err := testCase.Dump2YAML("ios_kuaishou_follow_live_test.yaml"); err != nil {
t.Fatal(err)
}
runner := hrp.NewRunner(t).SetSaveTests(true)
err := runner.Run(testCase)
if err != nil {
t.Fatal(err)
}
}

View File

@@ -0,0 +1,154 @@
{
"config": {
"name": "直播_快手_关注天窗_ios",
"variables": {
"device": "${ENV(UDID)}",
"ups": "大哥,王者"
},
"ios": [
{
"udid": "$device",
"port": 8100,
"mjpeg_port": 9100,
"log_on": true
}
]
},
"teststeps": [
{
"name": "启动快手",
"ios": {
"actions": [
{
"method": "app_terminate",
"params": "com.jiangjia.gif"
},
{
"method": "app_launch",
"params": "com.jiangjia.gif"
},
{
"method": "home"
},
{
"method": "swipe_to_tap_app",
"params": "快手",
"max_retry_times": 5
},
{
"method": "sleep",
"params": 10
}
]
},
"validate": [
{
"check": "ui_ocr",
"assert": "exists",
"expect": "精选",
"msg": "进入快手失败"
}
]
},
{
"name": "点击首页",
"ios": {
"actions": [
{
"method": "tap_ocr",
"params": "首页",
"index": -1
},
{
"method": "sleep",
"params": 10
}
]
}
},
{
"name": "点击发现页",
"ios": {
"actions": [
{
"method": "tap_ocr",
"params": "发现",
"index": 1
},
{
"method": "sleep",
"params": 10
}
]
}
},
{
"name": "点击关注页",
"ios": {
"actions": [
{
"method": "tap_ocr",
"params": "关注",
"index": 1
},
{
"method": "sleep",
"params": 10
}
]
}
},
{
"name": "点击直播标签,进入直播间",
"ios": {
"actions": [
{
"method": "swipe_to_tap_texts",
"params": [],
"identifier": "click_live",
"direction": [
0.6,
0.2,
0.2,
0.2
],
"function": "${split_by_comma($ups)}"
},
{
"method": "sleep",
"params": 60
}
]
},
"validate": [
{
"check": "ui_ocr",
"assert": "exists",
"expect": "说点什么",
"msg": "进入直播间失败"
}
]
},
{
"name": "下滑进入下一个直播间",
"ios": {
"actions": [
{
"method": "swipe",
"params": [
0.9,
0.7,
0.9,
0.3
],
"identifier": "slide_in_live"
},
{
"method": "sleep",
"params": 60
}
]
}
}
]
}

View File

@@ -0,0 +1,84 @@
config:
name: 直播_快手_关注天窗_ios
variables:
device: ${ENV(UDID)}
ups: 大哥,王者
ios:
- udid: $device
port: 8100
mjpeg_port: 9100
log_on: true
teststeps:
- name: 启动快手
ios:
actions:
- method: app_terminate
params: com.jiangjia.gif
- method: app_launch
params: com.jiangjia.gif
- method: home
- method: swipe_to_tap_app
params: 快手
max_retry_times: 5
- method: sleep
params: 10
validate:
- check: ui_ocr
assert: exists
expect: 精选
msg: 进入快手失败
- name: 点击首页
ios:
actions:
- method: tap_ocr
params: 首页
index: -1
- method: sleep
params: 10
- name: 点击发现页
ios:
actions:
- method: tap_ocr
params: 发现
index: 1
- method: sleep
params: 10
- name: 点击关注页
ios:
actions:
- method: tap_ocr
params: 关注
index: 1
- method: sleep
params: 10
- name: 点击直播标签,进入直播间
ios:
actions:
- method: swipe_to_tap_texts
params: []
identifier: click_live
direction:
- 0.6
- 0.2
- 0.2
- 0.2
function: ${split_by_comma($ups)}
- method: sleep
params: 60
validate:
- check: ui_ocr
assert: exists
expect: 说点什么
msg: 进入直播间失败
- name: 下滑进入下一个直播间
ios:
actions:
- method: swipe
params:
- 0.9
- 0.7
- 0.9
- 0.3
identifier: slide_in_live
- method: sleep
params: 60