mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
feat: add MobileUIPopupError code
This commit is contained in:
@@ -74,6 +74,7 @@ var (
|
|||||||
MobileUILaunchAppError = errors.New("mobile UI launch app error") // 71
|
MobileUILaunchAppError = errors.New("mobile UI launch app error") // 71
|
||||||
MobileUIValidationError = errors.New("mobile UI validation error") // 75
|
MobileUIValidationError = errors.New("mobile UI validation error") // 75
|
||||||
MobileUIAppNotInForegroundError = errors.New("mobile UI app not in foreground error") // 76
|
MobileUIAppNotInForegroundError = errors.New("mobile UI app not in foreground error") // 76
|
||||||
|
MobileUIPopupError = errors.New("mobile UI popup error") // 77
|
||||||
)
|
)
|
||||||
|
|
||||||
// OCR related: [80, 90)
|
// OCR related: [80, 90)
|
||||||
@@ -135,6 +136,7 @@ var errorsMap = map[error]int{
|
|||||||
MobileUILaunchAppError: 71,
|
MobileUILaunchAppError: 71,
|
||||||
MobileUIValidationError: 75,
|
MobileUIValidationError: 75,
|
||||||
MobileUIAppNotInForegroundError: 76,
|
MobileUIAppNotInForegroundError: 76,
|
||||||
|
MobileUIPopupError: 77,
|
||||||
|
|
||||||
// OCR related
|
// OCR related
|
||||||
OCREnvMissedError: 80,
|
OCREnvMissedError: 80,
|
||||||
|
|||||||
@@ -362,7 +362,8 @@ func (dExt *DriverExt) assertActivity(packageName, activityType string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if app.PackageName != packageName {
|
if app.PackageName != packageName {
|
||||||
return fmt.Errorf("app %s is not in foreground", packageName)
|
return errors.Wrap(code.MobileUIAppNotInForegroundError,
|
||||||
|
fmt.Sprintf("app %s is not in foreground", packageName))
|
||||||
}
|
}
|
||||||
|
|
||||||
if activities, ok := androidActivities[app.PackageName]; ok {
|
if activities, ok := androidActivities[app.PackageName]; ok {
|
||||||
@@ -374,7 +375,8 @@ func (dExt *DriverExt) assertActivity(packageName, activityType string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Error().Interface("app", app.AppBaseInfo).Msg("app activity not match")
|
log.Error().Interface("app", app.AppBaseInfo).Msg("app activity not match")
|
||||||
return fmt.Errorf("%s activity is not in foreground", activityType)
|
return errors.Wrap(code.MobileUIAppNotInForegroundError,
|
||||||
|
fmt.Sprintf("%s activity is not in foreground", activityType))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add more popup texts
|
// TODO: add more popup texts
|
||||||
@@ -396,7 +398,7 @@ func (dExt *DriverExt) autoPopupHandler(texts OCRTexts) error {
|
|||||||
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")
|
||||||
return err
|
return errors.Wrap(code.MobileUIPopupError, err.Error())
|
||||||
}
|
}
|
||||||
// tap popup success
|
// tap popup success
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user