mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
fix: tap x,y positions
This commit is contained in:
112
examples/uitest/wda_log_data.json
Normal file
112
examples/uitest/wda_log_data.json
Normal file
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"config": {
|
||||
"name": "验证 WDA 打点数据准确性",
|
||||
"variables": {
|
||||
"app_name": "抖音"
|
||||
},
|
||||
"ios": [
|
||||
{
|
||||
"port": 8700,
|
||||
"mjpeg_port": 8800,
|
||||
"log_on": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"teststeps": [
|
||||
{
|
||||
"name": "启动抖音",
|
||||
"ios": {
|
||||
"actions": [
|
||||
{
|
||||
"method": "home"
|
||||
},
|
||||
{
|
||||
"method": "app_terminate",
|
||||
"params": "com.ss.iphone.ugc.Aweme"
|
||||
},
|
||||
{
|
||||
"method": "swipe_to_tap_app",
|
||||
"params": "$app_name",
|
||||
"identifier": "启动抖音",
|
||||
"max_retry_times": 5
|
||||
},
|
||||
{
|
||||
"method": "sleep",
|
||||
"params": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
"validate": [
|
||||
{
|
||||
"check": "ui_ocr",
|
||||
"assert": "exists",
|
||||
"expect": "推荐",
|
||||
"msg": "抖音启动失败,「推荐」不存在"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "处理青少年弹窗",
|
||||
"ios": {
|
||||
"actions": [
|
||||
{
|
||||
"method": "tap_ocr",
|
||||
"params": "我知道了",
|
||||
"ignore_NotFoundError": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "向上滑动 2 次",
|
||||
"ios": {
|
||||
"actions": [
|
||||
{
|
||||
"method": "swipe",
|
||||
"params": "up",
|
||||
"identifier": "第 1 次上划"
|
||||
},
|
||||
{
|
||||
"method": "sleep",
|
||||
"params": 2
|
||||
},
|
||||
{
|
||||
"method": "swipe",
|
||||
"params": "up",
|
||||
"identifier": "第 2 次上划"
|
||||
},
|
||||
{
|
||||
"method": "sleep",
|
||||
"params": 2
|
||||
},
|
||||
{
|
||||
"method": "swipe",
|
||||
"params": "up",
|
||||
"identifier": "第 3 次上划"
|
||||
},
|
||||
{
|
||||
"method": "sleep",
|
||||
"params": 2
|
||||
},
|
||||
{
|
||||
"method": "tap_xy",
|
||||
"params": [
|
||||
0.9,
|
||||
0.1
|
||||
],
|
||||
"identifier": "点击进入搜索框"
|
||||
},
|
||||
{
|
||||
"method": "sleep",
|
||||
"params": 2
|
||||
},
|
||||
{
|
||||
"method": "input",
|
||||
"params": "httprunner",
|
||||
"identifier": "输入搜索关键词"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
48
examples/uitest/wda_log_test.go
Normal file
48
examples/uitest/wda_log_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
//go:build localtest
|
||||
|
||||
package uitest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
)
|
||||
|
||||
func TestWDALog(t *testing.T) {
|
||||
testCase := &hrp.TestCase{
|
||||
Config: hrp.NewConfig("验证 WDA 打点数据准确性").
|
||||
WithVariables(map[string]interface{}{
|
||||
"app_name": "抖音",
|
||||
}).
|
||||
SetIOS(hrp.WithLogOn(true), hrp.WithPort(8700), hrp.WithMjpegPort(8800)),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("启动抖音").
|
||||
IOS().
|
||||
Home().
|
||||
AppTerminate("com.ss.iphone.ugc.Aweme"). // 关闭已运行的抖音
|
||||
SwipeToTapApp("$app_name", hrp.WithMaxRetryTimes(5), hrp.WithIdentifier("启动抖音")).Sleep(5).
|
||||
Validate().
|
||||
AssertOCRExists("推荐", "抖音启动失败,「推荐」不存在"),
|
||||
hrp.NewStep("处理青少年弹窗").
|
||||
IOS().
|
||||
TapByOCR("我知道了", hrp.WithIgnoreNotFoundError(true)),
|
||||
hrp.NewStep("向上滑动 2 次").
|
||||
IOS().
|
||||
SwipeUp(hrp.WithIdentifier("第 1 次上划")).Sleep(2).
|
||||
SwipeUp(hrp.WithIdentifier("第 2 次上划")).Sleep(2).
|
||||
SwipeUp(hrp.WithIdentifier("第 3 次上划")).Sleep(2).
|
||||
TapXY(0.9, 0.1, hrp.WithIdentifier("点击进入搜索框")).Sleep(2).
|
||||
Input("httprunner", hrp.WithIdentifier("输入搜索关键词")),
|
||||
},
|
||||
}
|
||||
|
||||
if err := testCase.Dump2JSON("wda_log_data.json"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
runner := hrp.NewRunner(t).SetSaveTests(true)
|
||||
err := runner.Run(testCase)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user