mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 06:19:34 +08:00
feat: add code MobileUILaunchAppError
This commit is contained in:
@@ -68,6 +68,7 @@ var (
|
||||
// UI automation related: [70, 80)
|
||||
var (
|
||||
MobileUIDriverError = errors.New("mobile UI driver error") // 70
|
||||
MobileUILaunchAppError = errors.New("mobile UI launch app error") // 71
|
||||
MobileUIValidationError = errors.New("mobile UI validation error") // 75
|
||||
MobileUIAppNotInForegroundError = errors.New("mobile UI app not in foreground error") // 76
|
||||
)
|
||||
@@ -125,6 +126,7 @@ var errorsMap = map[error]int{
|
||||
|
||||
// UI automation related
|
||||
MobileUIDriverError: 70,
|
||||
MobileUILaunchAppError: 71,
|
||||
MobileUIValidationError: 75,
|
||||
MobileUIAppNotInForegroundError: 76,
|
||||
|
||||
|
||||
@@ -160,10 +160,12 @@ func (ad *adbDriver) AppLaunch(packageName string) (err error) {
|
||||
"monkey", "-p", packageName, "-c", "android.intent.category.LAUNCHER", "1",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(code.MobileUILaunchAppError,
|
||||
fmt.Sprintf("monkey launch failed: %v", err))
|
||||
}
|
||||
if strings.Contains(sOutput, "monkey aborted") {
|
||||
return fmt.Errorf("app launch: %s", strings.TrimSpace(sOutput))
|
||||
return errors.Wrap(code.MobileUILaunchAppError,
|
||||
fmt.Sprintf("monkey aborted: %s", strings.TrimSpace(sOutput)))
|
||||
}
|
||||
ad.lastLaunchedPackageName = packageName
|
||||
return nil
|
||||
|
||||
@@ -308,17 +308,23 @@ func (wd *wdaDriver) AppLaunch(bundleId string) (err error) {
|
||||
data := make(map[string]interface{})
|
||||
data["bundleId"] = bundleId
|
||||
_, err = wd.httpPOST(data, "/session", wd.sessionId, "/wda/apps/launch")
|
||||
if err == nil {
|
||||
wd.lastLaunchedPackageName = bundleId
|
||||
if err != nil {
|
||||
return errors.Wrap(code.MobileUILaunchAppError,
|
||||
fmt.Sprintf("wda launch failed: %v", err))
|
||||
}
|
||||
return
|
||||
wd.lastLaunchedPackageName = bundleId
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *wdaDriver) AppLaunchUnattached(bundleId string) (err error) {
|
||||
// [[FBRoute POST:@"/wda/apps/launchUnattached"].withoutSession respondWithTarget:self action:@selector(handleLaunchUnattachedApp:)]
|
||||
data := map[string]interface{}{"bundleId": bundleId}
|
||||
_, err = wd.httpPOST(data, "/wda/apps/launchUnattached")
|
||||
return
|
||||
if err != nil {
|
||||
return errors.Wrap(code.MobileUILaunchAppError,
|
||||
fmt.Sprintf("wda launchUnattached failed: %v", err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *wdaDriver) AppTerminate(bundleId string) (successful bool, err error) {
|
||||
|
||||
Reference in New Issue
Block a user