mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 17:59:36 +08:00
feat: add CallFunc action for MobileUI step
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0+2412232123
|
||||
v5.0.0+2412232231
|
||||
|
||||
@@ -35,6 +35,7 @@ const (
|
||||
ACTION_SetIme ActionMethod = "set_ime"
|
||||
ACTION_GetSource ActionMethod = "get_source"
|
||||
ACTION_GetForegroundApp ActionMethod = "get_foreground_app"
|
||||
ACTION_CallFunction ActionMethod = "call_function"
|
||||
|
||||
// UI handling
|
||||
ACTION_Home ActionMethod = "home"
|
||||
@@ -79,6 +80,7 @@ const (
|
||||
type MobileAction struct {
|
||||
Method ActionMethod `json:"method,omitempty" yaml:"method,omitempty"`
|
||||
Params interface{} `json:"params,omitempty" yaml:"params,omitempty"`
|
||||
Fn func() `json:"-" yaml:"-"` // only used for function action, not serialized
|
||||
Options *ActionOptions `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
ActionOptions
|
||||
}
|
||||
@@ -778,6 +780,10 @@ func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
|
||||
case ACTION_EndToEndDelay:
|
||||
CollectEndToEndDelay(dExt, action.GetOptions()...)
|
||||
return nil
|
||||
case ACTION_CallFunction:
|
||||
log.Info().Interface("name", action.Params).Msg("call function")
|
||||
fn := action.Fn
|
||||
fn()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -401,6 +401,16 @@ func (s *StepMobile) ClosePopups(options ...uixt.ActionOption) *StepMobile {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobile) CallFunc(name string, fn func()) *StepMobile {
|
||||
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||
Method: uixt.ACTION_CallFunction,
|
||||
Params: name,
|
||||
Fn: fn,
|
||||
Options: nil,
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
// Validate switches to step validation.
|
||||
func (s *StepMobile) Validate() *StepMobileUIValidation {
|
||||
return &StepMobileUIValidation{
|
||||
|
||||
Reference in New Issue
Block a user