From f1e4caeef8409b83dc581de239ab1037ce8f1387 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sun, 1 Sep 2024 17:05:38 +0800 Subject: [PATCH] change: remove duplicate code --- hrp/pkg/uixt/ext.go | 17 ----------------- hrp/pkg/uixt/screenshot.go | 9 +++++++++ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index 9b12d853..2ff92666 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -104,23 +104,6 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} { return cacheData } -// isPathExists returns true if path exists, whether path is file or dir -func isPathExists(path string) bool { - if _, err := os.Stat(path); os.IsNotExist(err) { - return false - } - return true -} - -func (dExt *DriverExt) FindUIRectInUIKit(search string, options ...ActionOption) (point PointF, err error) { - // click on text, using OCR - if !isPathExists(search) { - return dExt.FindScreenText(search, options...) - } - err = errors.New("ocr text not found") - return -} - func (dExt *DriverExt) AssertOCR(text, assert string) bool { var err error switch assert { diff --git a/hrp/pkg/uixt/screenshot.go b/hrp/pkg/uixt/screenshot.go index d4970fcd..75fd3eec 100644 --- a/hrp/pkg/uixt/screenshot.go +++ b/hrp/pkg/uixt/screenshot.go @@ -108,6 +108,15 @@ func (dExt *DriverExt) GetScreenTexts() (ocrTexts OCRTexts, err error) { return screenResult.Texts, nil } +func (dExt *DriverExt) FindUIRectInUIKit(search string, options ...ActionOption) (point PointF, err error) { + // click on text, using OCR + if !builtin.IsPathExists(search) { + return dExt.FindScreenText(search, options...) + } + err = errors.New("ocr text not found") + return +} + func (dExt *DriverExt) FindScreenText(text string, options ...ActionOption) (point PointF, err error) { ocrTexts, err := dExt.GetScreenTexts() if err != nil {