mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-23 05:17:41 +08:00
feat: add AIAction, do actions with LLM
This commit is contained in:
27
step_ui.go
27
step_ui.go
@@ -164,6 +164,18 @@ func (s *StepMobile) TapByUITypes(opts ...option.ActionOption) *StepMobile {
|
||||
return s
|
||||
}
|
||||
|
||||
// AIAction do actions with VLM
|
||||
func (s *StepMobile) AIAction(prompt string, opts ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_AIAction,
|
||||
Params: prompt,
|
||||
Options: option.NewActionOptions(opts...),
|
||||
}
|
||||
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
|
||||
// DoubleTapXY double taps the point {X,Y}, X & Y is percentage of coordinates
|
||||
func (s *StepMobile) DoubleTapXY(x, y float64, opts ...option.ActionOption) *StepMobile {
|
||||
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||
@@ -527,6 +539,21 @@ func (s *StepMobileUIValidation) AssertImageNotExists(expectedImagePath string,
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobileUIValidation) AssertByAI(prompt string, msg ...string) *StepMobileUIValidation {
|
||||
v := Validator{
|
||||
Check: uixt.SelectorAI,
|
||||
Assert: uixt.AssertionAI,
|
||||
Expect: prompt,
|
||||
}
|
||||
if len(msg) > 0 {
|
||||
v.Message = msg[0]
|
||||
} else {
|
||||
v.Message = fmt.Sprintf("assert ai prompt [%s] failed", prompt)
|
||||
}
|
||||
s.Validators = append(s.Validators, v)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobileUIValidation) AssertAppInForeground(packageName string, msg ...string) *StepMobileUIValidation {
|
||||
v := Validator{
|
||||
Check: uixt.SelectorForegroundApp,
|
||||
|
||||
Reference in New Issue
Block a user