diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 86ea9958..bf8c500b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## v4.3.4 (2023-05-04) +## v4.3.4 (2023-05-10) **go version** @@ -15,6 +15,7 @@ - refactor: FindText(s) returns OCRText(s) - refactor: merge ActionOption with DataOption - change: exit with AndroidShellExecError code for adb shell failure +- change: request vedem ocr with uploading image ## v4.3.3 (2023-04-19) diff --git a/examples/uitest/demo_android_video_crawler.json b/examples/uitest/demo_android_video_crawler.json index 6ad87edd..ce65f138 100644 --- a/examples/uitest/demo_android_video_crawler.json +++ b/examples/uitest/demo_android_video_crawler.json @@ -18,7 +18,7 @@ { "method": "video_crawler", "params": { - "app_package_name": "com.ss.android.ugc.aweme", + "app_package_name": "com.smile.gifmaker", "feed": { "sleep_random": [ 0, @@ -38,7 +38,7 @@ 1, 1 ], - "target": 1, + "target": 0, "text": "^广告$" }, { @@ -49,7 +49,7 @@ 1, 1 ], - "target": 1, + "target": 0, "text": "^图文$" }, { @@ -89,7 +89,7 @@ 15, 20 ], - "target_count": 3 + "target_count": 0 }, "timeout": 600 } diff --git a/examples/uitest/demo_android_video_crawler_test.go b/examples/uitest/demo_android_video_crawler_test.go index 2d6aaa45..3ce48f88 100644 --- a/examples/uitest/demo_android_video_crawler_test.go +++ b/examples/uitest/demo_android_video_crawler_test.go @@ -56,3 +56,49 @@ func TestAndroidVideoCrawlerTest(t *testing.T) { t.Fatal(err) } } + +func TestAndroidVideoCrawlerKSTest(t *testing.T) { + testCase := &hrp.TestCase{ + Config: hrp.NewConfig("抓取 KS 视频信息"). + WithVariables(map[string]interface{}{ + "device": "${ENV(SerialNumber)}", + }). + SetAndroid(uixt.WithSerialNumber("$device")), + TestSteps: []hrp.IStep{ + hrp.NewStep("滑动消费 feed 至少 100 个;滑动过程中,70% 随机间隔 0-5s,30% 随机间隔 5-10s"). + Android(). + VideoCrawler(map[string]interface{}{ + "app_package_name": "com.smile.gifmaker", + "timeout": 3600, + "feed": map[string]interface{}{ + "target_count": 100, + "target_labels": []map[string]interface{}{ + {"text": "^广告$", "scope": []float64{0, 0.5, 1, 1}, "regex": true}, + {"text": "^推广$", "scope": []float64{0, 0.5, 1, 1}, "regex": true}, + {"text": "^磁力广告$", "scope": []float64{0, 0.5, 1, 1}, "regex": true}, + }, + "sleep_random": []float64{0, 5, 0.7, 5, 10, 0.3}, + }, + "live": map[string]interface{}{ + "target_count": 0, + "sleep_random": []float64{15, 20}, + }, + }), + hrp.NewStep("exit"). + Android(). + AppTerminate("com.smile.gifmaker"). + Validate(). + AssertAppNotInForeground("com.smile.gifmaker"), + }, + } + + if err := testCase.Dump2JSON("demo_android_video_ks_crawler.json"); err != nil { + t.Fatal(err) + } + + runner := hrp.NewRunner(t).SetSaveTests(true) + err := runner.Run(testCase) + if err != nil { + t.Fatal(err) + } +} diff --git a/examples/uitest/demo_android_video_ks_crawler.json b/examples/uitest/demo_android_video_ks_crawler.json new file mode 100644 index 00000000..0ca26d1d --- /dev/null +++ b/examples/uitest/demo_android_video_ks_crawler.json @@ -0,0 +1,98 @@ +{ + "config": { + "name": "抓取 KS 视频信息", + "variables": { + "device": "${ENV(SerialNumber)}" + }, + "android": [ + { + "serial": "$device" + } + ] + }, + "teststeps": [ + { + "name": "滑动消费 feed 至少 100 个;滑动过程中,70% 随机间隔 0-5s,30% 随机间隔 5-10s", + "android": { + "actions": [ + { + "method": "video_crawler", + "params": { + "app_package_name": "com.smile.gifmaker", + "feed": { + "sleep_random": [ + 0, + 5, + 0.7, + 5, + 10, + 0.3 + ], + "target_count": 100, + "target_labels": [ + { + "regex": true, + "scope": [ + 0, + 0.5, + 1, + 1 + ], + "text": "^广告$" + }, + { + "regex": true, + "scope": [ + 0, + 0.5, + 1, + 1 + ], + "text": "^推广$" + }, + { + "regex": true, + "scope": [ + 0, + 0.5, + 1, + 1 + ], + "text": "^磁力广告$" + } + ] + }, + "live": { + "sleep_random": [ + 15, + 20 + ], + "target_count": 0 + }, + "timeout": 3600 + } + } + ] + } + }, + { + "name": "exit", + "android": { + "actions": [ + { + "method": "app_terminate", + "params": "com.smile.gifmaker" + } + ] + }, + "validate": [ + { + "check": "ui_foreground_app", + "assert": "not_equal", + "expect": "com.smile.gifmaker", + "msg": "app [com.smile.gifmaker] should not be in foreground" + } + ] + } + ] +} \ No newline at end of file diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 720b54ba..ccaca37a 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v4.3.4-beta-202305042235 \ No newline at end of file +v4.3.4-beta-202305101622 \ No newline at end of file diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 5e9968c4..8cf86f6e 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -199,12 +199,23 @@ type LiveCrawler struct { } func (l *LiveCrawler) checkLiveVideo(texts OCRTexts) (enterPoint PointF, yes bool) { - // 预览流入口 - points, err := texts.FindTexts([]string{".?点击进入直播间", "直播中"}, WithRegex(true)) + // 预览流入口:DY/KS + points, err := texts.FindTexts([]string{".?点击进入直播间"}, WithRegex(true)) if err == nil { return points[0].Center(), true } + // 预览流入口:KS + points, err = texts.FindTexts([]string{"和主播聊聊天.*"}, WithRegex(true)) + if err == nil { + point := points[0].Center() + enterPoint = PointF{ + X: point.X, + Y: point.Y - 100, + } + return enterPoint, true + } + // TODO: 头像入口 return PointF{}, false