diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 196ad69b..11d7a43e 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411132058 +v5.0.0+2411132151 diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index e73ca0ef..b6c8de87 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -2,6 +2,7 @@ package uixt import ( "context" + "fmt" _ "image/gif" _ "image/png" @@ -53,19 +54,24 @@ func newDriverExt(device IDevice, driver IWebDriver, options ...DriverOption) (d } func (dExt *DriverExt) AssertOCR(text, assert string) bool { + var options []ActionOption + options = append(options, WithScreenShotFileName(fmt.Sprintf("assert_ocr_%s", text))) + var err error switch assert { case AssertionEqual: - _, err = dExt.FindScreenText(text) + _, err = dExt.FindScreenText(text, options...) return err == nil case AssertionNotEqual: - _, err = dExt.FindScreenText(text) + _, err = dExt.FindScreenText(text, options...) return err != nil case AssertionExists: - _, err = dExt.FindScreenText(text, WithRegex(true)) + options = append(options, WithRegex(true)) + _, err = dExt.FindScreenText(text, options...) return err == nil case AssertionNotExists: - _, err = dExt.FindScreenText(text, WithRegex(true)) + options = append(options, WithRegex(true)) + _, err = dExt.FindScreenText(text, options...) return err != nil default: log.Warn().Str("assert method", assert).Msg("unexpected assert method") diff --git a/hrp/pkg/uixt/screenshot.go b/hrp/pkg/uixt/screenshot.go index 2d06ff9b..958e4b7a 100644 --- a/hrp/pkg/uixt/screenshot.go +++ b/hrp/pkg/uixt/screenshot.go @@ -126,11 +126,13 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S return screenResult, nil } -func (dExt *DriverExt) GetScreenTexts() (ocrTexts OCRTexts, err error) { - screenResult, err := dExt.GetScreenResult( - WithScreenShotOCR(true), WithScreenShotUpload(true), - WithScreenShotFileName("get_screen_texts"), - ) +func (dExt *DriverExt) GetScreenTexts(options ...ActionOption) (ocrTexts OCRTexts, err error) { + actionOptions := NewActionOptions(options...) + if actionOptions.ScreenShotFileName == "" { + options = append(options, WithScreenShotFileName("get_screen_texts")) + } + options = append(options, WithScreenShotOCR(true), WithScreenShotUpload(true)) + screenResult, err := dExt.GetScreenResult(options...) if err != nil { return } @@ -148,7 +150,11 @@ func (dExt *DriverExt) FindUIRectInUIKit(search string, options ...ActionOption) } func (dExt *DriverExt) FindScreenText(text string, options ...ActionOption) (point PointF, err error) { - ocrTexts, err := dExt.GetScreenTexts() + actionOptions := NewActionOptions(options...) + if actionOptions.ScreenShotFileName == "" { + options = append(options, WithScreenShotFileName(fmt.Sprintf("find_screen_text_%s", text))) + } + ocrTexts, err := dExt.GetScreenTexts(options...) if err != nil { return } @@ -166,8 +172,11 @@ func (dExt *DriverExt) FindScreenText(text string, options ...ActionOption) (poi } func (dExt *DriverExt) FindUIResult(options ...ActionOption) (point PointF, err error) { - options = append(options, WithScreenShotFileName("find_ui_result")) actionOptions := NewActionOptions(options...) + if actionOptions.ScreenShotFileName == "" { + options = append(options, WithScreenShotFileName( + fmt.Sprintf("find_ui_result_%s", strings.Join(actionOptions.ScreenShotWithUITypes, "_")))) + } screenResult, err := dExt.GetScreenResult(options...) if err != nil { diff --git a/hrp/pkg/uixt/tap.go b/hrp/pkg/uixt/tap.go index dcf1ff0d..edb6a58f 100644 --- a/hrp/pkg/uixt/tap.go +++ b/hrp/pkg/uixt/tap.go @@ -34,6 +34,9 @@ func (dExt *DriverExt) TapXY(x, y float64, options ...ActionOption) error { func (dExt *DriverExt) TapByOCR(ocrText string, options ...ActionOption) error { actionOptions := NewActionOptions(options...) + if actionOptions.ScreenShotFileName == "" { + options = append(options, WithScreenShotFileName(fmt.Sprintf("tap_by_ocr_%s", ocrText))) + } point, err := dExt.FindScreenText(ocrText, options...) if err != nil {