diff --git a/hrp/internal/uixt/android_driver.go b/hrp/internal/uixt/android_driver.go index 80385504..85363014 100644 --- a/hrp/internal/uixt/android_driver.go +++ b/hrp/internal/uixt/android_driver.go @@ -676,6 +676,14 @@ func (ud *uiaDriver) SendKeys(text string, options ...DataOption) (err error) { return } +func (ud *uiaDriver) Input(text string, options ...DataOption) (err error) { + element, err := ud.FindElement(BySelector{ClassName: ElementType{EditText: true}}) + if err != nil { + return err + } + return element.SendKeys(text) +} + func (ud *uiaDriver) KeyboardDismiss(keyNames ...string) (err error) { // TODO return errDriverNotImplemented diff --git a/hrp/internal/uixt/ext.go b/hrp/internal/uixt/ext.go index 29642168..0970edb2 100644 --- a/hrp/internal/uixt/ext.go +++ b/hrp/internal/uixt/ext.go @@ -301,45 +301,6 @@ func (dExt *DriverExt) IsImageExist(text string) bool { return err == nil } -func (dExt *DriverExt) StartLogRecording(identifier string) error { - if _, ok := dExt.Driver.(*wdaDriver); ok { - log.Info().Msg("start WDA log recording") - data := map[string]interface{}{"action": "start", "type": 2, "identifier": identifier} - _, err := dExt.triggerWDALog(data) - if err != nil { - return errors.Wrap(err, "failed to start WDA log recording") - } - } else { - log.Info().Msg("start adb log recording") - err := dExt.Driver.(*uiaDriver).logcat.CatchLogcat() - if err != nil { - return errors.Wrap(err, "failed to start adb log recording") - } - } - return nil -} - -func (dExt *DriverExt) GetLogs() (interface{}, error) { - if _, ok := dExt.Driver.(*wdaDriver); ok { - log.Info().Msg("stop WDA log recording") - data := map[string]interface{}{"action": "stop"} - reply, err := dExt.triggerWDALog(data) - if err != nil { - return "", errors.Wrap(err, "failed to get WDA logs") - } - return reply.Value, nil - } else { - log.Info().Msg("stop adb log recording") - err := dExt.Driver.(*uiaDriver).logcat.Stop() - if err != nil { - println("failed to get adb log recording") - //return "", errors.Wrap(err, "failed to get adb log recording") - } - content := dExt.Driver.(*uiaDriver).logcat.logBuffer.String() - return ConvertPoints(content), err - } -} - var errActionNotImplemented = errors.New("UI action not implemented") func (dExt *DriverExt) DoAction(action MobileAction) error { @@ -508,9 +469,9 @@ func (dExt *DriverExt) DoAction(action MobileAction) error { "enable": true, "data": action.Identifier, }) - return dExt.Driver.SendKeys(param, option) + return dExt.Driver.Input(param, option) } - return dExt.Driver.SendKeys(param) + return dExt.Driver.Input(param) case CtlSleep: if param, ok := action.Params.(json.Number); ok { seconds, _ := param.Float64() diff --git a/hrp/internal/uixt/interface.go b/hrp/internal/uixt/interface.go index cbc7c668..c341ac97 100644 --- a/hrp/internal/uixt/interface.go +++ b/hrp/internal/uixt/interface.go @@ -715,6 +715,7 @@ type ElementType struct { Tab bool `json:"XCUIElementTypeTab"` TouchBar bool `json:"XCUIElementTypeTouchBar"` StatusItem bool `json:"XCUIElementTypeStatusItem"` + EditText bool `json:"android.widget.EditText"` } // ProtectedResource A system resource that requires user authorization to access. @@ -927,6 +928,9 @@ type WebDriver interface { // WithFrequency option can be used to set frequency of typing (letters per sec). The default value is 60 SendKeys(text string, options ...DataOption) error + // Input works like SendKeys + Input(text string, options ...DataOption) error + // KeyboardDismiss Tries to dismiss the on-screen keyboard KeyboardDismiss(keyNames ...string) error diff --git a/hrp/internal/uixt/ios_driver.go b/hrp/internal/uixt/ios_driver.go index ac4159f0..7dfbcbde 100644 --- a/hrp/internal/uixt/ios_driver.go +++ b/hrp/internal/uixt/ios_driver.go @@ -527,6 +527,10 @@ func (wd *wdaDriver) SendKeys(text string, options ...DataOption) (err error) { return } +func (wd *wdaDriver) Input(text string, options ...DataOption) (err error) { + return wd.SendKeys(text, options...) +} + func (wd *wdaDriver) KeyboardDismiss(keyNames ...string) (err error) { // [[FBRoute POST:@"/wda/keyboard/dismiss"] respondWithTarget:self action:@selector(handleDismissKeyboardCommand:)] if len(keyNames) == 0 {