feat: scenario detect of mobile ui automation

This commit is contained in:
xucong.053
2023-04-19 19:29:34 +08:00
committed by xucong.053
parent ef9eaa7e38
commit 3591f72913
7 changed files with 199 additions and 91 deletions
+9 -3
View File
@@ -274,7 +274,7 @@ func (v *responseObject) searchRegexp(expr string) interface{} {
return expr
}
func validateUI(ud *uixt.DriverExt, iValidators []interface{}) (validateResults []*ValidationResult, err error) {
func validateUI(ud *uixt.DriverExt, iValidators []interface{}, parser *Parser, variablesMapping map[string]interface{}) (validateResults []*ValidationResult, err error) {
for _, iValidator := range iValidators {
validator, ok := iValidator.(Validator)
if !ok {
@@ -287,14 +287,20 @@ func validateUI(ud *uixt.DriverExt, iValidators []interface{}) (validateResults
}
// parse check value
if !strings.HasPrefix(validator.Check, "ui_") {
if !strings.HasPrefix(validator.Check, "ui_") && !strings.HasPrefix(validator.Check, "scenario") {
validataResult.CheckResult = "skip"
log.Warn().Interface("validator", validator).Msg("skip validator")
validateResults = append(validateResults, validataResult)
continue
}
expected, ok := validator.Expect.(string)
// parse expected value
expectValue, err := parser.Parse(validator.Expect, variablesMapping)
if err != nil {
return nil, errors.New("validator expect should be string")
}
expected, ok := expectValue.(string)
if !ok {
return nil, errors.New("validator expect should be string")
}