From 57fc782bb675f82ec4df86a8a283bf5231da1bd2 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 27 Jul 2022 22:52:26 +0800 Subject: [PATCH] feat: input text on current active element --- hrp/step_ios_ui.go | 7 +++++-- hrp/step_ui_test.go | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/hrp/step_ios_ui.go b/hrp/step_ios_ui.go index 2607a038..b4795446 100644 --- a/hrp/step_ios_ui.go +++ b/hrp/step_ios_ui.go @@ -428,8 +428,11 @@ func (w *wdaClient) doAction(action MobileAction) error { } return w.Driver.Swipe(fromX, fromY, toX, toY) case uiInput: - // TODO - return errActionNotImplemented + // input text on current active element + // append \n to send text with enter + // send \b\b\b to delete 3 chars + param := fmt.Sprintf("%v", action.Params) + return w.Driver.SendKeys(param) case appClick: // TODO return errActionNotImplemented diff --git a/hrp/step_ui_test.go b/hrp/step_ui_test.go index 02739b51..6022c73f 100644 --- a/hrp/step_ui_test.go +++ b/hrp/step_ui_test.go @@ -47,6 +47,25 @@ func TestIOSSettingsAction(t *testing.T) { } } +func TestIOSSearchApp(t *testing.T) { + testCase := &TestCase{ + Config: NewConfig("ios ui action on Search App 资源库"), + TestSteps: []IStep{ + NewStep("进入 App 资源库 搜索框"). + IOS().Home().SwipeLeft().SwipeLeft().Click("dewey-search-field"). + Validate(). + AssertNameExists("取消", "「取消」不存在"), + NewStep("搜索抖音"). + IOS().Input("抖音\n"), + }, + } + + err := NewRunner(t).Run(testCase) + if err != nil { + t.Fatal(err) + } +} + func TestIOSDouyinAction(t *testing.T) { testCase := &TestCase{ Config: NewConfig("ios ui action on 抖音"),