change popup close status from bool to string

This commit is contained in:
buyuxiang
2023-08-28 17:58:55 +08:00
parent afe304f58c
commit b0ccd504de
4 changed files with 27 additions and 26 deletions

View File

@@ -88,25 +88,25 @@ func (screenResults ScreenResultMap) getScreenShotUrls() map[string]string {
return screenShotsUrls return screenShotsUrls
} }
// checkPopupInfo checks if popup closed normally in every screenResult with close_popups on: // updatePopupCloseStatus checks if popup closed normally in every screenResult with close_popups on:
func (screenResults ScreenResultMap) checkPopupInfo() { func (screenResults ScreenResultMap) updatePopupCloseStatus() {
var screenResultList []*ScreenResult var popupScreenResultList []*ScreenResult
for _, screenResult := range screenResults { for _, screenResult := range screenResults {
if screenResult.Popup == nil { if screenResult.Popup == nil {
continue continue
} }
screenResultList = append(screenResultList, screenResult) popupScreenResultList = append(popupScreenResultList, screenResult)
} }
if len(screenResultList) == 0 { if len(popupScreenResultList) == 0 {
return return
} }
sort.Slice(screenResultList, func(i, j int) bool { sort.Slice(popupScreenResultList, func(i, j int) bool {
return screenResultList[i].Popup.RetryCount < screenResultList[j].Popup.RetryCount return popupScreenResultList[i].Popup.RetryCount < popupScreenResultList[j].Popup.RetryCount
}) })
for i := 0; i < len(screenResultList)-1; i++ { for i := 0; i < len(popupScreenResultList)-1; i++ {
curPopup := screenResultList[i].Popup curPopup := popupScreenResultList[i].Popup
nextPopup := screenResultList[i+1].Popup nextPopup := popupScreenResultList[i+1].Popup
// popup not existed, no need to close // popup not existed, no need to close
if curPopup.CloseArea.IsEmpty() { if curPopup.CloseArea.IsEmpty() {
@@ -114,10 +114,11 @@ func (screenResults ScreenResultMap) checkPopupInfo() {
} }
// popup existed, but identical popups occurs during next retry // popup existed, but identical popups occurs during next retry
if curPopup.Text == nextPopup.Text && curPopup.Type == nextPopup.Type { if curPopup.Text == nextPopup.Text && curPopup.Type == nextPopup.Type {
popupScreenResultList[i].Popup.CloseStatus = "fail"
continue continue
} }
// popup existed, but no popup or different popup occurs during next retry (IsClosed=true) // popup existed, but no popup or different popup occurs during next retry (IsClosed=true)
screenResultList[i].Popup.IsClosed = true popupScreenResultList[i].Popup.CloseStatus = "success"
} }
} }
@@ -273,7 +274,7 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} {
cacheData["screenshots"] = dExt.cacheStepData.screenShots cacheData["screenshots"] = dExt.cacheStepData.screenShots
cacheData["screenshots_urls"] = dExt.cacheStepData.screenResults.getScreenShotUrls() cacheData["screenshots_urls"] = dExt.cacheStepData.screenResults.getScreenShotUrls()
dExt.cacheStepData.screenResults.checkPopupInfo() dExt.cacheStepData.screenResults.updatePopupCloseStatus()
screenSize, err := dExt.Driver.WindowSize() screenSize, err := dExt.Driver.WindowSize()
if err != nil { if err != nil {

View File

@@ -203,7 +203,7 @@ func (wd *wdaDriver) WindowSize() (size Size, err error) {
size = reply.Value.Size size = reply.Value.Size
scale, err := wd.Scale() scale, err := wd.Scale()
if err != nil { if err != nil {
return Size{}, errors.Wrap(err, "get window size failed when obtaining scale") return Size{}, errors.Wrap(err, "get window size scale failed")
} }
size.Height = size.Height * int(scale) size.Height = size.Height * int(scale)
size.Width = size.Width * int(scale) size.Width = size.Width * int(scale)

View File

@@ -74,8 +74,8 @@ func (dExt *DriverExt) AutoPopupHandler() error {
return dExt.handleTextPopup(screenResult.Texts) return dExt.handleTextPopup(screenResult.Texts)
} }
// CRResult represents the result of recognized popup to close // ClosePopupsResult represents the result of recognized popup to close
type CPResult struct { type ClosePopupsResult struct {
Type string `json:"type"` Type string `json:"type"`
PopupArea Box `json:"popupArea"` PopupArea Box `json:"popupArea"`
CloseArea Box `json:"closeArea"` CloseArea Box `json:"closeArea"`
@@ -83,14 +83,14 @@ type CPResult struct {
} }
type PopupInfo struct { type PopupInfo struct {
IsClosed bool `json:"is_closed"` CloseStatus string `json:"close_status"`
Type string `json:"type"` Type string `json:"type"`
Text string `json:"text"` Text string `json:"text"`
RetryCount int `json:"retry_count"` RetryCount int `json:"retry_count"`
PicName string `json:"pic_name"` PicName string `json:"pic_name"`
PicURL string `json:"pic_url"` PicURL string `json:"pic_url"`
PopupArea Box `json:"popup_area"` PopupArea Box `json:"popup_area"`
CloseArea Box `json:"close_area"` CloseArea Box `json:"close_area"`
} }
func (dExt *DriverExt) ClosePopups(options ...ActionOption) error { func (dExt *DriverExt) ClosePopups(options ...ActionOption) error {

View File

@@ -66,9 +66,9 @@ type ImageResult struct {
// Media媒体 // Media媒体
// Chat语音 // Chat语音
// Event赛事 // Event赛事
LiveType string `json:"liveType"` // 直播间类型 LiveType string `json:"liveType"` // 直播间类型
UIResult UIResultMap `json:"uiResult"` // 图标检测 UIResult UIResultMap `json:"uiResult"` // 图标检测
CPResult CPResult `json:"closeResult"` // 弹窗按钮检测 CPResult ClosePopupsResult `json:"closeResult"` // 弹窗按钮检测
} }
type APIResponseImage struct { type APIResponseImage struct {