mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 16:40:50 +08:00
fix: step duration equals to action sum
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2412241024
|
v5.0.0+2412241212
|
||||||
|
|||||||
@@ -781,7 +781,6 @@ func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
|
|||||||
CollectEndToEndDelay(dExt, action.GetOptions()...)
|
CollectEndToEndDelay(dExt, action.GetOptions()...)
|
||||||
return nil
|
return nil
|
||||||
case ACTION_CallFunction:
|
case ACTION_CallFunction:
|
||||||
log.Info().Interface("name", action.Params).Msg("call function")
|
|
||||||
fn := action.Fn
|
fn := action.Fn
|
||||||
fn()
|
fn()
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-2
@@ -401,10 +401,10 @@ func (s *StepMobile) ClosePopups(options ...uixt.ActionOption) *StepMobile {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepMobile) CallFunc(name string, fn func()) *StepMobile {
|
func (s *StepMobile) Call(name string, fn func()) *StepMobile {
|
||||||
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||||
Method: uixt.ACTION_CallFunction,
|
Method: uixt.ACTION_CallFunction,
|
||||||
Params: name,
|
Params: name, // function description
|
||||||
Fn: fn,
|
Fn: fn,
|
||||||
Options: nil,
|
Options: nil,
|
||||||
})
|
})
|
||||||
@@ -675,18 +675,38 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
|||||||
attachments["error"] = err.Error()
|
attachments["error"] = err.Error()
|
||||||
|
|
||||||
// save foreground app
|
// save foreground app
|
||||||
|
startTime := time.Now()
|
||||||
|
actionResult := &ActionResult{
|
||||||
|
MobileAction: uixt.MobileAction{
|
||||||
|
Method: uixt.ACTION_GetForegroundApp,
|
||||||
|
Params: "[ForDebug] check foreground app",
|
||||||
|
},
|
||||||
|
StartTime: startTime.Unix(),
|
||||||
|
}
|
||||||
if app, err1 := uiDriver.Driver.GetForegroundApp(); err1 == nil {
|
if app, err1 := uiDriver.Driver.GetForegroundApp(); err1 == nil {
|
||||||
attachments["foreground_app"] = app.AppBaseInfo
|
attachments["foreground_app"] = app.AppBaseInfo
|
||||||
} else {
|
} else {
|
||||||
log.Warn().Err(err1).Msg("save foreground app failed, ignore")
|
log.Warn().Err(err1).Msg("save foreground app failed, ignore")
|
||||||
}
|
}
|
||||||
|
actionResult.Elapsed = time.Since(startTime).Milliseconds()
|
||||||
|
stepResult.Actions = append(stepResult.Actions, actionResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
// automatic handling of pop-up windows on each step finished
|
// automatic handling of pop-up windows on each step finished
|
||||||
if !ignorePopup && !s.caseRunner.Config.Get().IgnorePopup {
|
if !ignorePopup && !s.caseRunner.Config.Get().IgnorePopup {
|
||||||
|
startTime := time.Now()
|
||||||
|
actionResult := &ActionResult{
|
||||||
|
MobileAction: uixt.MobileAction{
|
||||||
|
Method: uixt.ACTION_ClosePopups,
|
||||||
|
Params: "[ForDebug] close popups handler",
|
||||||
|
},
|
||||||
|
StartTime: startTime.Unix(),
|
||||||
|
}
|
||||||
if err2 := uiDriver.ClosePopupsHandler(); err2 != nil {
|
if err2 := uiDriver.ClosePopupsHandler(); err2 != nil {
|
||||||
log.Error().Err(err2).Str("step", step.Name()).Msg("auto handle popup failed")
|
log.Error().Err(err2).Str("step", step.Name()).Msg("auto handle popup failed")
|
||||||
}
|
}
|
||||||
|
actionResult.Elapsed = time.Since(startTime).Milliseconds()
|
||||||
|
stepResult.Actions = append(stepResult.Actions, actionResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
// save attachments
|
// save attachments
|
||||||
|
|||||||
Reference in New Issue
Block a user