fix: keep compatibility for config ignore_popup

This commit is contained in:
lilong.129
2025-07-21 22:00:48 +08:00
parent fbca5907c9
commit 9c4a945db6
6 changed files with 32 additions and 9 deletions

View File

@@ -1077,6 +1077,24 @@ func (r *SessionRunner) GetTransactions() map[string]map[TransactionType]time.Ti
return r.transactions
}
// keep for compatibility
func (r *SessionRunner) ignorePopup(osType string) bool {
config := r.caseRunner.TestCase.Config.Get()
if osType == string(StepTypeAndroid) && len(config.Android) > 0 {
return config.Android[0].IgnorePopup
}
if osType == string(StepTypeIOS) && len(config.IOS) > 0 {
return config.IOS[0].IgnorePopup
}
if osType == string(StepTypeHarmony) && len(config.Harmony) > 0 {
return config.Harmony[0].IgnorePopup
}
if osType == string(stepTypeBrowser) && len(config.Browser) > 0 {
return config.Browser[0].IgnorePopup
}
return false
}
// saveJSONCase saves the original JSON case content to the results directory
func saveJSONCase(casePath string) error {
// Read the original JSON case content

View File

@@ -798,10 +798,11 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
config = s.caseRunner.Config.Get()
}
// automatic handling of pop-up windows on each step finished, default to disabled
// priority: step ignore_popup > config auto_popup_handler > step auto_popup_handler
// priority: config ignore_popup > step ignore_popup > config auto_popup_handler > step auto_popup_handler
shouldHandlePopup := false
if stepIgnorePopup {
if s.ignorePopup(mobileStep.OSType) {
shouldHandlePopup = false
} else if stepIgnorePopup {
// step level config, keep for compatibility
shouldHandlePopup = false
} else if config != nil && config.AutoPopupHandler {

View File

@@ -5,6 +5,7 @@ import "github.com/httprunner/httprunner/v5/pkg/gadb"
type AndroidDeviceOptions struct {
SerialNumber string `json:"serial,omitempty" yaml:"serial,omitempty"`
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` // keep for compatibility
// adb
AdbServerHost string `json:"adb_server_host,omitempty" yaml:"adb_server_host,omitempty"`

View File

@@ -9,10 +9,11 @@ func NewBrowserDeviceOptions(opts ...BrowserDeviceOption) *BrowserDeviceOptions
}
type BrowserDeviceOptions struct {
BrowserID string `json:"browser_id,omitempty" yaml:"browser_id,omitempty"`
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
Width int `json:"width,omitempty" yaml:"width,omitempty"`
Height int `json:"height,omitempty" yaml:"height,omitempty"`
BrowserID string `json:"browser_id,omitempty" yaml:"browser_id,omitempty"`
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` // keep for compatibility
Width int `json:"width,omitempty" yaml:"width,omitempty"`
Height int `json:"height,omitempty" yaml:"height,omitempty"`
}
func (dev *BrowserDeviceOptions) Options() (deviceOptions []BrowserDeviceOption) {

View File

@@ -8,8 +8,9 @@ const (
)
type HarmonyDeviceOptions struct {
ConnectKey string `json:"connect_key,omitempty" yaml:"connect_key,omitempty"`
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
ConnectKey string `json:"connect_key,omitempty" yaml:"connect_key,omitempty"`
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` // keep for compatibility
}
func (dev *HarmonyDeviceOptions) Options() (deviceOptions []HarmonyDeviceOption) {

View File

@@ -6,6 +6,7 @@ type IOSDeviceOptions struct {
WDAPort int `json:"port,omitempty" yaml:"port,omitempty"` // WDA remote port
WDAMjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"` // WDA remote MJPEG port
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` // keep for compatibility
// switch to iOS springboard before init WDA session
ResetHomeOnStartup bool `json:"reset_home_on_startup,omitempty" yaml:"reset_home_on_startup,omitempty"`