diff --git a/hrp/pkg/uixt/ios_driver.go b/hrp/pkg/uixt/ios_driver.go index 8bfee256..33d86a44 100644 --- a/hrp/pkg/uixt/ios_driver.go +++ b/hrp/pkg/uixt/ios_driver.go @@ -201,6 +201,12 @@ func (wd *wdaDriver) WindowSize() (size Size, err error) { return Size{}, err } size = reply.Value.Size + scale, err := wd.Scale() + if err != nil { + return Size{}, errors.Wrap(err, "get window size failed when obtaining scale") + } + size.Height = size.Height * int(scale) + size.Width = size.Width * int(scale) return } diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index f2912fc8..1c81e500 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -357,8 +357,12 @@ type IImageService interface { // GetScreenResult takes a screenshot, returns the image recognization result func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *ScreenResult, err error) { startTime := time.Now() + fileName := builtin.GenNameWithTimestamp("%d_screenshot") actionOptions := NewActionOptions(options...) - fileName := builtin.GenNameWithTimestamp("%d_" + strings.Join(actionOptions.screenshotActions(), "_")) + screenshotActions := actionOptions.screenshotActions() + if len(screenshotActions) != 0 { + fileName = builtin.GenNameWithTimestamp("%d_" + strings.Join(screenshotActions, "_")) + } bufSource, imagePath, err := dExt.takeScreenShot(fileName) if err != nil { return diff --git a/hrp/pkg/uixt/service_vedem_test.go b/hrp/pkg/uixt/service_vedem_test.go index df7eb793..78ed8b4b 100644 --- a/hrp/pkg/uixt/service_vedem_test.go +++ b/hrp/pkg/uixt/service_vedem_test.go @@ -102,22 +102,17 @@ func TestClosePopup(t *testing.T) { setupAndroid(t) screenResult, err := driverExt.GetScreenResult( - WithScreenShotClose(true), WithScreenShotUpload(true)) + WithScreenShotClosePopups(true), WithScreenShotUpload(true)) if err != nil { t.Logf("get screen result failed for popup handler: %v", err) return } - t.Logf("screen result: %v", screenResult) - // 1. there are no popups here (fast return normally) - // 2. failed to close popup (maybe tap error, return error) - // 3. successful to close popup (sleep and wait for next retry if existed) if screenResult.Popup == nil { t.Log("there are no popups here") return } - t.Logf("popup info: %v", screenResult.Popup) if err = driverExt.tapPopupHandler(screenResult.Popup); err != nil { diff --git a/hrp/pkg/uixt/tap.go b/hrp/pkg/uixt/tap.go index df200117..a992c94e 100644 --- a/hrp/pkg/uixt/tap.go +++ b/hrp/pkg/uixt/tap.go @@ -15,12 +15,8 @@ func (dExt *DriverExt) TapXY(x, y float64, options ...ActionOption) error { return fmt.Errorf("x, y percentage should be <= 1, got x=%v, y=%v", x, y) } - scale, err := dExt.Driver.Scale() - if err != nil { - return fmt.Errorf("failed to get scale: %v", err) - } - x = x * float64(dExt.windowSize.Width) * scale - y = y * float64(dExt.windowSize.Height) * scale + x = x * float64(dExt.windowSize.Width) + y = y * float64(dExt.windowSize.Height) return dExt.TapAbsXY(x, y, options...) }