change: autoPopupHandler

This commit is contained in:
lilong.129
2023-05-04 20:32:52 +08:00
parent 5d9fa3c91e
commit f720eaacfb
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -423,9 +423,8 @@ func (dExt *DriverExt) assertActivity(packageName, activityType string) error {
// TODO: add more popup texts // TODO: add more popup texts
var popups = [][]string{ var popups = [][]string{
{"青少年", "我知道了"}, // 青少年弹窗 {"青少年模式", "我知道了"}, // 青少年弹窗
{"允许", "拒绝"}, {"个人信息保护指引", "同意"},
{"确定", "取消"},
} }
func (dExt *DriverExt) autoPopupHandler(ocrResult *OcrResult) error { func (dExt *DriverExt) autoPopupHandler(ocrResult *OcrResult) error {
@@ -434,9 +433,10 @@ func (dExt *DriverExt) autoPopupHandler(ocrResult *OcrResult) error {
continue continue
} }
points, err := ocrResult.Texts.FindTexts([]string{"确定", "取消"}) points, err := ocrResult.Texts.FindTexts([]string{popup[0], popup[1]})
if err == nil { if err == nil {
log.Warn().Msg("text popup found") log.Warn().Interface("popup", popup).
Interface("texts", ocrResult.Texts).Msg("text popup found")
point := points[1].Center() point := points[1].Center()
if err := dExt.TapAbsXY(point.X, point.Y); err != nil { if err := dExt.TapAbsXY(point.X, point.Y); err != nil {
log.Error().Err(err).Msg("tap popup failed") log.Error().Err(err).Msg("tap popup failed")
+2 -2
View File
@@ -14,8 +14,8 @@ func TestVideoCrawler(t *testing.T) {
Feed: FeedConfig{ Feed: FeedConfig{
TargetCount: 5, TargetCount: 5,
TargetLabels: []TargetLabel{ TargetLabels: []TargetLabel{
{Text: `^广告$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true, Target: 2}, {Text: `^广告$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
{Text: `^图文$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true}, {Text: `^图文$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true, Target: 2},
{Text: `^特效\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true}, {Text: `^特效\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
{Text: `^模板\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true}, {Text: `^模板\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
{Text: `^购物\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true}, {Text: `^购物\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},