mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-06 06:51:23 +08:00
refactor: integrate and optimize MCP tool calling methods
This commit is contained in:
21
step_ui.go
21
step_ui.go
@@ -448,6 +448,16 @@ func (s *StepMobile) ClosePopups(opts ...option.ActionOption) *StepMobile {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobile) Call(name string, fn func(), opts ...option.ActionOption) *StepMobile {
|
||||
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||
Method: option.ACTION_CallFunction,
|
||||
Params: name, // function description
|
||||
Fn: fn,
|
||||
Options: option.NewActionOptions(opts...),
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
// Validate switches to step validation.
|
||||
func (s *StepMobile) Validate() *StepMobileUIValidation {
|
||||
return &StepMobileUIValidation{
|
||||
@@ -804,6 +814,17 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
||||
continue
|
||||
}
|
||||
|
||||
// call custom function
|
||||
if action.Method == option.ACTION_CallFunction {
|
||||
if funcDesc, ok := action.Params.(string); ok {
|
||||
err := uiDriver.Call(funcDesc, action.Fn, action.GetOptions()...)
|
||||
if err != nil {
|
||||
return stepResult, err
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
err = uiDriver.ExecuteAction(context.Background(), action)
|
||||
actionResult.Elapsed = time.Since(actionStartTime).Milliseconds()
|
||||
stepResult.Actions = append(stepResult.Actions, actionResult)
|
||||
|
||||
Reference in New Issue
Block a user