mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 08:27:35 +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_SetIme ActionMethod = "set_ime"
|
||||||
ACTION_GetSource ActionMethod = "get_source"
|
ACTION_GetSource ActionMethod = "get_source"
|
||||||
ACTION_GetForegroundApp ActionMethod = "get_foreground_app"
|
ACTION_GetForegroundApp ActionMethod = "get_foreground_app"
|
||||||
|
ACTION_CallFunction ActionMethod = "call_function"
|
||||||
|
|
||||||
// UI handling
|
// UI handling
|
||||||
ACTION_Home ActionMethod = "home"
|
ACTION_Home ActionMethod = "home"
|
||||||
@@ -79,6 +80,7 @@ const (
|
|||||||
type MobileAction struct {
|
type MobileAction struct {
|
||||||
Method ActionMethod `json:"method,omitempty" yaml:"method,omitempty"`
|
Method ActionMethod `json:"method,omitempty" yaml:"method,omitempty"`
|
||||||
Params interface{} `json:"params,omitempty" yaml:"params,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"`
|
Options *ActionOptions `json:"options,omitempty" yaml:"options,omitempty"`
|
||||||
ActionOptions
|
ActionOptions
|
||||||
}
|
}
|
||||||
@@ -778,6 +780,10 @@ func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
|
|||||||
case ACTION_EndToEndDelay:
|
case ACTION_EndToEndDelay:
|
||||||
CollectEndToEndDelay(dExt, action.GetOptions()...)
|
CollectEndToEndDelay(dExt, action.GetOptions()...)
|
||||||
return nil
|
return nil
|
||||||
|
case ACTION_CallFunction:
|
||||||
|
log.Info().Interface("name", action.Params).Msg("call function")
|
||||||
|
fn := action.Fn
|
||||||
|
fn()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -401,6 +401,16 @@ func (s *StepMobile) ClosePopups(options ...uixt.ActionOption) *StepMobile {
|
|||||||
return s
|
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.
|
// Validate switches to step validation.
|
||||||
func (s *StepMobile) Validate() *StepMobileUIValidation {
|
func (s *StepMobile) Validate() *StepMobileUIValidation {
|
||||||
return &StepMobileUIValidation{
|
return &StepMobileUIValidation{
|
||||||
|
|||||||
Reference in New Issue
Block a user