diff --git a/hrp/step.go b/hrp/step.go index 507182a4..87c48953 100644 --- a/hrp/step.go +++ b/hrp/step.go @@ -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" diff --git a/hrp/step_android_ui.go b/hrp/step_android_ui.go index 8dac1687..abc1a9be 100644 --- a/hrp/step_android_ui.go +++ b/hrp/step_android_ui.go @@ -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 diff --git a/hrp/step_android_ui_test.go b/hrp/step_android_ui_test.go index 13d3cba9..7ca077f9 100644 --- a/hrp/step_android_ui_test.go +++ b/hrp/step_android_ui_test.go @@ -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(), }, diff --git a/hrp/step_ios_ui.go b/hrp/step_ios_ui.go index bf02c121..6c458c6a 100644 --- a/hrp/step_ios_ui.go +++ b/hrp/step_ios_ui.go @@ -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) -}