mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
change: autoPopupHandler
This commit is contained in:
@@ -423,9 +423,8 @@ func (dExt *DriverExt) assertActivity(packageName, activityType string) error {
|
||||
|
||||
// TODO: add more popup texts
|
||||
var popups = [][]string{
|
||||
{"青少年", "我知道了"}, // 青少年弹窗
|
||||
{"允许", "拒绝"},
|
||||
{"确定", "取消"},
|
||||
{"青少年模式", "我知道了"}, // 青少年弹窗
|
||||
{"个人信息保护指引", "同意"},
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) autoPopupHandler(ocrResult *OcrResult) error {
|
||||
@@ -434,9 +433,10 @@ func (dExt *DriverExt) autoPopupHandler(ocrResult *OcrResult) error {
|
||||
continue
|
||||
}
|
||||
|
||||
points, err := ocrResult.Texts.FindTexts([]string{"确定", "取消"})
|
||||
points, err := ocrResult.Texts.FindTexts([]string{popup[0], popup[1]})
|
||||
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()
|
||||
if err := dExt.TapAbsXY(point.X, point.Y); err != nil {
|
||||
log.Error().Err(err).Msg("tap popup failed")
|
||||
|
||||
@@ -14,8 +14,8 @@ func TestVideoCrawler(t *testing.T) {
|
||||
Feed: FeedConfig{
|
||||
TargetCount: 5,
|
||||
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},
|
||||
|
||||
Reference in New Issue
Block a user