diff --git a/hrp/step_android_ui.go b/hrp/step_android_ui.go index 9aa851f7..f49adb6d 100644 --- a/hrp/step_android_ui.go +++ b/hrp/step_android_ui.go @@ -172,6 +172,17 @@ type StepAndroidValidation struct { step *TStep } +func (s *StepAndroidValidation) AssertTextExists(expectedText string, msg string) *StepAndroidValidation { + v := Validator{ + Check: "android_ui", + Assert: "text_exists", + Expect: expectedText, + Message: msg, + } + s.step.Validators = append(s.step.Validators, v) + return s +} + func (s *StepAndroidValidation) Name() string { return s.step.Name } diff --git a/hrp/step_ios_ui.go b/hrp/step_ios_ui.go index b6903e80..cf2fb8c4 100644 --- a/hrp/step_ios_ui.go +++ b/hrp/step_ios_ui.go @@ -132,6 +132,17 @@ type StepIOSValidation struct { step *TStep } +func (s *StepIOSValidation) AssertTextExists(expectedText string, msg string) *StepIOSValidation { + v := Validator{ + Check: "ios_ui", + Assert: "text_exists", + Expect: expectedText, + Message: msg, + } + s.step.Validators = append(s.step.Validators, v) + return s +} + func (s *StepIOSValidation) Name() string { return s.step.Name } diff --git a/hrp/step_ui_test.go b/hrp/step_ui_test.go index 91d730a9..02e2044e 100644 --- a/hrp/step_ui_test.go +++ b/hrp/step_ui_test.go @@ -10,7 +10,10 @@ func TestAndroidAction(t *testing.T) { Config: NewConfig("android ui action"), TestSteps: []IStep{ NewStep("launch douyin"). - Android().Serial("xxx").Click("抖音"), + Android().Serial("xxx").Click("抖音"). + Validate(). + AssertTextExists("首页", "首页 tab 不存在"). + AssertTextExists("消息", "消息 tab 不存在"), NewStep("swipe up and down"). Android().Serial("xxx").SwipeUp().SwipeUp().SwipeDown(), }, @@ -29,7 +32,10 @@ func TestIOSAction(t *testing.T) { Config: NewConfig("ios ui action"), TestSteps: []IStep{ NewStep("launch douyin"). - IOS().UDID("xxx").Click("抖音"), + IOS().UDID("xxx").Click("抖音"). + Validate(). + AssertTextExists("首页", "首页 tab 不存在"). + AssertTextExists("消息", "消息 tab 不存在"), NewStep("swipe up and down"). IOS().UDID("xxx").SwipeUp().SwipeUp().SwipeDown(), },