mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-07 16:59:34 +08:00
fix: update error handling in runStepMobileUI to store error messages as strings
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2506201912
|
v5.0.0-beta-2506201936
|
||||||
|
|||||||
2
step.go
2
step.go
@@ -60,7 +60,7 @@ type ActionResult struct {
|
|||||||
option.MobileAction `json:",inline"`
|
option.MobileAction `json:",inline"`
|
||||||
StartTime int64 `json:"start_time"` // action start time in millisecond(ms)
|
StartTime int64 `json:"start_time"` // action start time in millisecond(ms)
|
||||||
Elapsed int64 `json:"elapsed_ms"` // action elapsed time(ms)
|
Elapsed int64 `json:"elapsed_ms"` // action elapsed time(ms)
|
||||||
Error error `json:"error,omitempty"` // action execution result
|
Error string `json:"error,omitempty"` // action execution result
|
||||||
Plannings []*uixt.PlanningExecutionResult `json:"plannings,omitempty"` // store planning results for start_to_goal actions, which contains multiple sub-actions
|
Plannings []*uixt.PlanningExecutionResult `json:"plannings,omitempty"` // store planning results for start_to_goal actions, which contains multiple sub-actions
|
||||||
uixt.SessionData // store session data for other actions besides start_to_goal
|
uixt.SessionData // store session data for other actions besides start_to_goal
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
|||||||
sessionData, err1 := uiDriver.ExecuteAction(
|
sessionData, err1 := uiDriver.ExecuteAction(
|
||||||
context.Background(), actionResult.MobileAction)
|
context.Background(), actionResult.MobileAction)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
actionResult.Error = err1
|
actionResult.Error = err1.Error()
|
||||||
log.Warn().Err(err1).Msg("get foreground app failed, ignore")
|
log.Warn().Err(err1).Msg("get foreground app failed, ignore")
|
||||||
}
|
}
|
||||||
actionResult.Elapsed = time.Since(startTime).Milliseconds()
|
actionResult.Elapsed = time.Since(startTime).Milliseconds()
|
||||||
@@ -831,7 +831,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
|||||||
sessionData, err2 := uiDriver.ExecuteAction(
|
sessionData, err2 := uiDriver.ExecuteAction(
|
||||||
context.Background(), actionResult.MobileAction)
|
context.Background(), actionResult.MobileAction)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
actionResult.Error = err2
|
actionResult.Error = err2.Error()
|
||||||
log.Warn().Err(err2).Str("step", step.Name()).Msg("auto handle popup failed")
|
log.Warn().Err(err2).Str("step", step.Name()).Msg("auto handle popup failed")
|
||||||
}
|
}
|
||||||
actionResult.Elapsed = time.Since(startTime).Milliseconds()
|
actionResult.Elapsed = time.Since(startTime).Milliseconds()
|
||||||
@@ -953,11 +953,11 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
|||||||
|
|
||||||
// handle other actions
|
// handle other actions
|
||||||
sessionData, err := uiDriver.ExecuteAction(ctx, action)
|
sessionData, err := uiDriver.ExecuteAction(ctx, action)
|
||||||
actionResult.Error = err
|
|
||||||
actionResult.Elapsed = time.Since(actionStartTime).Milliseconds()
|
actionResult.Elapsed = time.Since(actionStartTime).Milliseconds()
|
||||||
actionResult.SessionData = sessionData
|
actionResult.SessionData = sessionData
|
||||||
stepResult.Actions = append(stepResult.Actions, actionResult)
|
stepResult.Actions = append(stepResult.Actions, actionResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
actionResult.Error = err.Error()
|
||||||
if !code.IsErrorPredefined(err) {
|
if !code.IsErrorPredefined(err) {
|
||||||
err = errors.Wrap(code.MobileUIDriverError, err.Error())
|
err = errors.Wrap(code.MobileUIDriverError, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user