mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +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
|
// 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")
|
||||||
|
|||||||
@@ -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},
|
||||||
|
|||||||
Reference in New Issue
Block a user