mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-27 02:21:23 +08:00
change: AIAssert
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0-beta-2503251425
|
||||
v5.0.0-beta-2503251433
|
||||
|
||||
@@ -539,7 +539,7 @@ func (s *StepMobileUIValidation) AssertImageNotExists(expectedImagePath string,
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobileUIValidation) AssertByAI(prompt string, msg ...string) *StepMobileUIValidation {
|
||||
func (s *StepMobileUIValidation) AssertAI(prompt string, msg ...string) *StepMobileUIValidation {
|
||||
v := Validator{
|
||||
Check: uixt.SelectorAI,
|
||||
Assert: uixt.AssertionAI,
|
||||
|
||||
@@ -80,3 +80,21 @@ func TestAndroidAction(t *testing.T) {
|
||||
err := hrp.NewRunner(t).Run(testCase)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestAIAction(t *testing.T) {
|
||||
testCase := &hrp.TestCase{
|
||||
Config: hrp.NewConfig("run ui action with ai"),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("launch settings").
|
||||
Android().AIAction("进入手机系统设置").
|
||||
Validate().
|
||||
AssertAI("当前位于手机设置页面"),
|
||||
hrp.NewStep("turn on fly mode").
|
||||
Android().AIAction("开启飞行模式").
|
||||
Validate().
|
||||
AssertAI("飞行模式已开启"),
|
||||
},
|
||||
}
|
||||
err := hrp.NewRunner(t).Run(testCase)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -55,6 +55,14 @@ func (dExt *XTDriver) AIAction(text string, opts ...option.ActionOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dExt *XTDriver) AIQuery(text string, opts ...option.ActionOption) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (dExt *XTDriver) AIAssert(text string, opts ...option.ActionOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dExt *XTDriver) PlanNextAction(text string, opts ...option.ActionOption) (*ai.PlanningResult, error) {
|
||||
if dExt.LLMService == nil {
|
||||
return nil, errors.New("LLM service is not initialized")
|
||||
|
||||
@@ -185,8 +185,12 @@ func (dExt *XTDriver) DoValidation(check, assert, expected string, message ...st
|
||||
switch check {
|
||||
case SelectorOCR:
|
||||
err = dExt.assertOCR(expected, assert)
|
||||
// case SelectorAI:
|
||||
// // TODO
|
||||
case SelectorForegroundApp:
|
||||
err = dExt.assertForegroundApp(expected, assert)
|
||||
default:
|
||||
return fmt.Errorf("validator %s not implemented", check)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -198,7 +202,8 @@ func (dExt *XTDriver) DoValidation(check, assert, expected string, message ...st
|
||||
return err
|
||||
}
|
||||
|
||||
log.Info().Str("assert", assert).Str("expect", expected).Msg("validate success")
|
||||
log.Info().Str("check", check).Str("assert", assert).
|
||||
Str("expect", expected).Msg("validate success")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user