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
}
// checkPopupInfo checks if popup closed normally in every screenResult with close_popups on:
func (screenResults ScreenResultMap) checkPopupInfo() {
var screenResultList []*ScreenResult
// updatePopupCloseStatus checks if popup closed normally in every screenResult with close_popups on:
func (screenResults ScreenResultMap) updatePopupCloseStatus() {
var popupScreenResultList []*ScreenResult
for _, screenResult := range screenResults {
if screenResult.Popup == nil {
continue
}
screenResultList = append(screenResultList, screenResult)
popupScreenResultList = append(popupScreenResultList, screenResult)
}
if len(screenResultList) == 0 {
if len(popupScreenResultList) == 0 {
return
}
sort.Slice(screenResultList, func(i, j int) bool {
return screenResultList[i].Popup.RetryCount < screenResultList[j].Popup.RetryCount
sort.Slice(popupScreenResultList, func(i, j int) bool {
return popupScreenResultList[i].Popup.RetryCount < popupScreenResultList[j].Popup.RetryCount
})
for i := 0; i < len(screenResultList)-1; i++ {
curPopup := screenResultList[i].Popup
nextPopup := screenResultList[i+1].Popup
for i := 0; i < len(popupScreenResultList)-1; i++ {
curPopup := popupScreenResultList[i].Popup
nextPopup := popupScreenResultList[i+1].Popup
// popup not existed, no need to close
if curPopup.CloseArea.IsEmpty() {
@@ -114,10 +114,11 @@ func (screenResults ScreenResultMap) checkPopupInfo() {
}
// popup existed, but identical popups occurs during next retry
if curPopup.Text == nextPopup.Text && curPopup.Type == nextPopup.Type {
popupScreenResultList[i].Popup.CloseStatus = "fail"
continue
}
// 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_urls"] = dExt.cacheStepData.screenResults.getScreenShotUrls()
dExt.cacheStepData.screenResults.checkPopupInfo()
dExt.cacheStepData.screenResults.updatePopupCloseStatus()
screenSize, err := dExt.Driver.WindowSize()
if err != nil {

View File

@@ -203,7 +203,7 @@ func (wd *wdaDriver) WindowSize() (size Size, err error) {
size = reply.Value.Size
scale, err := wd.Scale()
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.Width = size.Width * int(scale)

View File

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

View File

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