change: remove xpath validation

This commit is contained in:
debugtalk
2022-08-28 10:31:16 +08:00
parent bfc8f89cba
commit 98f0f5de90
4 changed files with 11 additions and 52 deletions

View File

@@ -42,7 +42,6 @@ const (
// UI validation
uiSelectorName string = "ui_name"
uiSelectorXpath string = "ui_xpath"
uiSelectorOCR string = "ui_ocr"
assertionExists string = "exists"
assertionNotExists string = "not_exists"

View File

@@ -158,31 +158,31 @@ type StepAndroidValidation struct {
step *TStep
}
func (s *StepAndroidValidation) AssertXpathExists(expectedXpath string, msg ...string) *StepAndroidValidation {
func (s *StepAndroidValidation) AssertNameExists(expectedName string, msg ...string) *StepAndroidValidation {
v := Validator{
Check: uiSelectorXpath,
Check: uiSelectorName,
Assert: assertionExists,
Expect: expectedXpath,
Expect: expectedName,
}
if len(msg) > 0 {
v.Message = msg[0]
} else {
v.Message = fmt.Sprintf("xpath [%s] not found", expectedXpath)
v.Message = fmt.Sprintf("[%s] not found", expectedName)
}
s.step.Validators = append(s.step.Validators, v)
return s
}
func (s *StepAndroidValidation) AssertXpathNotExists(expectedXpath string, msg ...string) *StepAndroidValidation {
func (s *StepAndroidValidation) AssertNameNotExists(expectedName string, msg ...string) *StepAndroidValidation {
v := Validator{
Check: uiSelectorXpath,
Check: uiSelectorName,
Assert: assertionNotExists,
Expect: expectedXpath,
Expect: expectedName,
}
if len(msg) > 0 {
v.Message = msg[0]
} else {
v.Message = fmt.Sprintf("xpath [%s] should not exist", expectedXpath)
v.Message = fmt.Sprintf("[%s] should not exist", expectedName)
}
s.step.Validators = append(s.step.Validators, v)
return s

View File

@@ -10,10 +10,10 @@ func TestAndroidAction(t *testing.T) {
Config: NewConfig("android ui action"),
TestSteps: []IStep{
NewStep("launch douyin").
Android().Serial("xxx").Click("抖音").
Android().Serial("xxx").Tap("抖音").
Validate().
AssertXpathExists("首页", "首页 tab 不存在").
AssertXpathExists("消息", "消息 tab 不存在"),
AssertNameExists("首页", "首页 tab 不存在").
AssertNameExists("消息", "消息 tab 不存在"),
NewStep("swipe up and down").
Android().Serial("xxx").SwipeUp().SwipeUp().SwipeDown(),
},

View File

@@ -288,36 +288,6 @@ func (s *StepIOSValidation) AssertNameNotExists(expectedName string, msg ...stri
return s
}
func (s *StepIOSValidation) AssertXpathExists(expectedXpath string, msg ...string) *StepIOSValidation {
v := Validator{
Check: uiSelectorXpath,
Assert: assertionExists,
Expect: expectedXpath,
}
if len(msg) > 0 {
v.Message = msg[0]
} else {
v.Message = fmt.Sprintf("xpath [%s] not found", expectedXpath)
}
s.step.Validators = append(s.step.Validators, v)
return s
}
func (s *StepIOSValidation) AssertXpathNotExists(expectedXpath string, msg ...string) *StepIOSValidation {
v := Validator{
Check: uiSelectorXpath,
Assert: assertionNotExists,
Expect: expectedXpath,
}
if len(msg) > 0 {
v.Message = msg[0]
} else {
v.Message = fmt.Sprintf("xpath [%s] should not exist", expectedXpath)
}
s.step.Validators = append(s.step.Validators, v)
return s
}
func (s *StepIOSValidation) Name() string {
return s.step.Name
}
@@ -628,8 +598,6 @@ func (w *wdaClient) doValidation(iValidators []interface{}) (validateResults []*
switch validator.Check {
case uiSelectorName:
result = w.assertName(expected, exists)
case uiSelectorXpath:
result = w.assertXpath(expected, exists)
}
if result {
@@ -659,11 +627,3 @@ func (w *wdaClient) assertName(name string, exists bool) bool {
_, err := w.DriverExt.FindElement(selector)
return exists == (err == nil)
}
func (w *wdaClient) assertXpath(xpath string, exists bool) bool {
selector := gwda.BySelector{
XPath: xpath,
}
_, err := w.DriverExt.FindElement(selector)
return exists == (err == nil)
}