mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-11 15:31:37 +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
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepMobileUIValidation) AssertByAI(prompt string, msg ...string) *StepMobileUIValidation {
|
func (s *StepMobileUIValidation) AssertAI(prompt string, msg ...string) *StepMobileUIValidation {
|
||||||
v := Validator{
|
v := Validator{
|
||||||
Check: uixt.SelectorAI,
|
Check: uixt.SelectorAI,
|
||||||
Assert: uixt.AssertionAI,
|
Assert: uixt.AssertionAI,
|
||||||
|
|||||||
@@ -80,3 +80,21 @@ func TestAndroidAction(t *testing.T) {
|
|||||||
err := hrp.NewRunner(t).Run(testCase)
|
err := hrp.NewRunner(t).Run(testCase)
|
||||||
assert.Nil(t, err)
|
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
|
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) {
|
func (dExt *XTDriver) PlanNextAction(text string, opts ...option.ActionOption) (*ai.PlanningResult, error) {
|
||||||
if dExt.LLMService == nil {
|
if dExt.LLMService == nil {
|
||||||
return nil, errors.New("LLM service is not initialized")
|
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 {
|
switch check {
|
||||||
case SelectorOCR:
|
case SelectorOCR:
|
||||||
err = dExt.assertOCR(expected, assert)
|
err = dExt.assertOCR(expected, assert)
|
||||||
|
// case SelectorAI:
|
||||||
|
// // TODO
|
||||||
case SelectorForegroundApp:
|
case SelectorForegroundApp:
|
||||||
err = dExt.assertForegroundApp(expected, assert)
|
err = dExt.assertForegroundApp(expected, assert)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("validator %s not implemented", check)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -198,7 +202,8 @@ func (dExt *XTDriver) DoValidation(check, assert, expected string, message ...st
|
|||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user