MCPcopy
hub / github.com/httprunner/httprunner / DoAction

Method DoAction

hrp/pkg/uixt/action.go:474–651  ·  view source on GitHub ↗
(action MobileAction)

Source from the content-addressed store, hash-verified

472}
473
474func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
475 log.Debug().
476 Str("method", string(action.Method)).
477 Interface("params", action.Params).
478 Msg("uixt action start")
479 actionStartTime := time.Now()
480
481 defer func() {
482 if err != nil {
483 log.Error().Err(err).
484 Str("method", string(action.Method)).
485 Interface("params", action.Params).
486 Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()).
487 Msg("uixt action end")
488 } else {
489 log.Debug().
490 Str("method", string(action.Method)).
491 Interface("params", action.Params).
492 Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()).
493 Msg("uixt action end")
494 }
495 }()
496
497 switch action.Method {
498 case ACTION_AppInstall:
499 // TODO
500 return errActionNotImplemented
501 case ACTION_AppLaunch:
502 if bundleId, ok := action.Params.(string); ok {
503 return dExt.Driver.AppLaunch(bundleId)
504 }
505 return fmt.Errorf("invalid %s params, should be bundleId(string), got %v",
506 ACTION_AppLaunch, action.Params)
507 case ACTION_SwipeToTapApp:
508 if appName, ok := action.Params.(string); ok {
509 return dExt.swipeToTapApp(appName, action.GetOptions()...)
510 }
511 return fmt.Errorf("invalid %s params, should be app name(string), got %v",
512 ACTION_SwipeToTapApp, action.Params)
513 case ACTION_SwipeToTapText:
514 if text, ok := action.Params.(string); ok {
515 return dExt.swipeToTapTexts([]string{text}, action.GetOptions()...)
516 }
517 return fmt.Errorf("invalid %s params, should be app text(string), got %v",
518 ACTION_SwipeToTapText, action.Params)
519 case ACTION_SwipeToTapTexts:
520 if texts, ok := action.Params.([]string); ok {
521 return dExt.swipeToTapTexts(texts, action.GetOptions()...)
522 }
523 if texts, err := builtin.ConvertToStringSlice(action.Params); err == nil {
524 return dExt.swipeToTapTexts(texts, action.GetOptions()...)
525 }
526 return fmt.Errorf("invalid %s params: %v", ACTION_SwipeToTapTexts, action.Params)
527 case ACTION_AppTerminate:
528 if bundleId, ok := action.Params.(string); ok {
529 success, err := dExt.Driver.AppTerminate(bundleId)
530 if err != nil {
531 return errors.Wrap(err, "failed to terminate app")

Callers 1

runStepMobileUIFunction · 0.80

Calls 15

swipeToTapAppMethod · 0.95
swipeToTapTextsMethod · 0.95
TapXYMethod · 0.95
TapAbsXYMethod · 0.95
TapMethod · 0.95
TapByOCRMethod · 0.95
TapByCVMethod · 0.95
TapByUIDetectionMethod · 0.95
DoubleTapXYMethod · 0.95
DoubleTapMethod · 0.95
prepareSwipeActionMethod · 0.95
GetScreenResultMethod · 0.95

Tested by

no test coverage detected