diff --git a/hrp/config.go b/hrp/config.go index 85b63568..2f3add6e 100644 --- a/hrp/config.go +++ b/hrp/config.go @@ -41,6 +41,7 @@ type TConfig struct { Weight int `json:"weight,omitempty" yaml:"weight,omitempty"` Path string `json:"path,omitempty" yaml:"path,omitempty"` // testcase file path PluginSetting *PluginConfig `json:"plugin,omitempty" yaml:"plugin,omitempty"` // plugin config + IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` } func (c *TConfig) Get() *TConfig { @@ -179,6 +180,11 @@ func (c *TConfig) SetAndroid(options ...uixt.AndroidDeviceOption) *TConfig { return c } +func (s *TConfig) DisableAutoPopupHandler() *TConfig { + s.IgnorePopup = true + return s +} + type ThinkTimeConfig struct { Strategy thinkTimeStrategy `json:"strategy,omitempty" yaml:"strategy,omitempty"` // default、random、multiply、ignore Setting interface{} `json:"setting,omitempty" yaml:"setting,omitempty"` // random(map): {"min_percentage": 0.5, "max_percentage": 1.5}; 10、multiply(float64): 1.5 diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 11d7a43e..6dab0e8a 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411132151 +v5.0.0+2411141441 diff --git a/hrp/pkg/uixt/android_device.go b/hrp/pkg/uixt/android_device.go index 92eac758..b82e177e 100644 --- a/hrp/pkg/uixt/android_device.go +++ b/hrp/pkg/uixt/android_device.go @@ -169,7 +169,6 @@ type AndroidDevice struct { UIA2IP string `json:"uia2_ip,omitempty" yaml:"uia2_ip,omitempty"` // uiautomator2 server ip UIA2Port int `json:"uia2_port,omitempty" yaml:"uia2_port,omitempty"` // uiautomator2 server port LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"` - IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` } func (dev *AndroidDevice) Options() (deviceOptions []AndroidDeviceOption) { diff --git a/hrp/pkg/uixt/harmony_device.go b/hrp/pkg/uixt/harmony_device.go index a4dbd220..a8d3d44c 100644 --- a/hrp/pkg/uixt/harmony_device.go +++ b/hrp/pkg/uixt/harmony_device.go @@ -16,19 +16,15 @@ var ( ) type HarmonyDevice struct { - d *ghdc.Device - ConnectKey string `json:"connect_key,omitempty" yaml:"connect_key,omitempty"` - IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` - LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"` + d *ghdc.Device + ConnectKey string `json:"connect_key,omitempty" yaml:"connect_key,omitempty"` + LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"` } func (dev *HarmonyDevice) Options() (deviceOptions []HarmonyDeviceOption) { if dev.ConnectKey != "" { deviceOptions = append(deviceOptions, WithConnectKey(dev.ConnectKey)) } - if dev.IgnorePopup { - deviceOptions = append(deviceOptions, WithIgnorePopup(true)) - } if dev.LogOn { deviceOptions = append(deviceOptions, WithLogOn(true)) } @@ -43,12 +39,6 @@ func WithConnectKey(connectKey string) HarmonyDeviceOption { } } -func WithIgnorePopup(ignorePopup bool) HarmonyDeviceOption { - return func(device *HarmonyDevice) { - device.IgnorePopup = ignorePopup - } -} - func WithLogOn(logOn bool) HarmonyDeviceOption { return func(device *HarmonyDevice) { device.LogOn = logOn diff --git a/hrp/pkg/uixt/ios_device.go b/hrp/pkg/uixt/ios_device.go index d2566e12..1bcf69cb 100644 --- a/hrp/pkg/uixt/ios_device.go +++ b/hrp/pkg/uixt/ios_device.go @@ -240,7 +240,6 @@ type IOSDevice struct { MjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"` // WDA remote MJPEG port LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"` XCTestBundleID string `json:"xctest_bundle_id,omitempty" yaml:"xctest_bundle_id,omitempty"` - IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` // switch to iOS springboard before init WDA session ResetHomeOnStartup bool `json:"reset_home_on_startup,omitempty" yaml:"reset_home_on_startup,omitempty"` diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index 6970f9e5..0de373d5 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -392,6 +392,11 @@ func (s *StepMobile) StopCamera() *StepMobile { return s } +func (s *StepMobile) DisableAutoPopupHandler() *StepMobile { + s.IgnorePopup = true + return s +} + func (s *StepMobile) ClosePopups(options ...uixt.ActionOption) *StepMobile { s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{ Method: uixt.ACTION_ClosePopups, @@ -669,7 +674,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err } // automatic handling of pop-up windows on each step finished - if !ignorePopup && !s.IgnorePopup() { + if !ignorePopup && !s.caseRunner.Config.Get().IgnorePopup { if err2 := uiDriver.ClosePopupsHandler(); err2 != nil { log.Error().Err(err2).Str("step", step.Name()).Msg("auto handle popup failed") }