mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +08:00
feat: add live type
This commit is contained in:
+9
-7
@@ -52,9 +52,11 @@ func WithThreshold(threshold float64) CVOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ScreenResult struct {
|
type ScreenResult struct {
|
||||||
bufSource *bytes.Buffer // raw image buffer bytes
|
bufSource *bytes.Buffer // raw image buffer bytes
|
||||||
imagePath string // image file path
|
imagePath string // image file path
|
||||||
|
imageResult *ImageResult // image result
|
||||||
|
|
||||||
|
LiveType string
|
||||||
UploadedURL string `json:"uploaded_url"` // uploaded image url
|
UploadedURL string `json:"uploaded_url"` // uploaded image url
|
||||||
Texts OCRTexts `json:"texts"` // dumped raw OCRTexts
|
Texts OCRTexts `json:"texts"` // dumped raw OCRTexts
|
||||||
Icons UIResultMap `json:"icons"` // CV 识别的图标
|
Icons UIResultMap `json:"icons"` // CV 识别的图标
|
||||||
@@ -74,16 +76,16 @@ type ScreenResult struct {
|
|||||||
TotalElapsed int64 `json:"total_elapsed"` // current_swipe_finish -> next_swipe_start 整体耗时(ms)
|
TotalElapsed int64 `json:"total_elapsed"` // current_swipe_finish -> next_swipe_start 整体耗时(ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScreenResultMap map[string]*ScreenResult
|
type ScreenResultMap map[string]*ScreenResult // key is date time
|
||||||
|
|
||||||
// getScreenShotUrls returns screenShotsUrls using imagePath as key and uploaded URL as value
|
// getScreenShotUrls returns screenShotsUrls using imagePath as key and uploaded URL as value
|
||||||
func (screenResults ScreenResultMap) getScreenShotUrls() map[string]string {
|
func (screenResults ScreenResultMap) getScreenShotUrls() map[string]string {
|
||||||
screenShotsUrls := make(map[string]string)
|
screenShotsUrls := make(map[string]string)
|
||||||
for imagePath, screenResult := range screenResults {
|
for dateTime, screenResult := range screenResults {
|
||||||
if screenResult.UploadedURL == "" {
|
if screenResult.UploadedURL == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
screenShotsUrls[imagePath] = screenResult.UploadedURL
|
screenShotsUrls[dateTime] = screenResult.UploadedURL
|
||||||
}
|
}
|
||||||
return screenShotsUrls
|
return screenShotsUrls
|
||||||
}
|
}
|
||||||
@@ -282,7 +284,7 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} {
|
|||||||
screenSize = Size{}
|
screenSize = Size{}
|
||||||
}
|
}
|
||||||
screenResults := make(map[string]interface{})
|
screenResults := make(map[string]interface{})
|
||||||
for imagePath, screenResult := range dExt.cacheStepData.screenResults {
|
for dateTime, screenResult := range dExt.cacheStepData.screenResults {
|
||||||
o, _ := json.Marshal(screenResult.Texts)
|
o, _ := json.Marshal(screenResult.Texts)
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"tags": screenResult.Tags,
|
"tags": screenResult.Tags,
|
||||||
@@ -303,7 +305,7 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} {
|
|||||||
"popup": screenResult.Popup,
|
"popup": screenResult.Popup,
|
||||||
}
|
}
|
||||||
|
|
||||||
screenResults[imagePath] = data
|
screenResults[dateTime] = data
|
||||||
}
|
}
|
||||||
cacheData["screen_results"] = screenResults
|
cacheData["screen_results"] = screenResults
|
||||||
|
|
||||||
|
|||||||
@@ -388,9 +388,7 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
screenResult.Icons = imageResult.UIResult
|
screenResult.Icons = imageResult.UIResult
|
||||||
|
|
||||||
if imageResult.LiveType != "" && imageResult.LiveType != "NoLive" {
|
if imageResult.LiveType != "" && imageResult.LiveType != "NoLive" {
|
||||||
screenResult.Live = &LiveRoom{
|
screenResult.LiveType = imageResult.LiveType
|
||||||
LiveType: imageResult.LiveType,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if actionOptions.ScreenShotWithClosePopups {
|
if actionOptions.ScreenShotWithClosePopups {
|
||||||
screenResult.Popup = &PopupInfo{
|
screenResult.Popup = &PopupInfo{
|
||||||
@@ -405,7 +403,7 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dExt.cacheStepData.screenResults[imagePath] = screenResult
|
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
||||||
|
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Str("imagePath", imagePath).
|
Str("imagePath", imagePath).
|
||||||
|
|||||||
@@ -178,9 +178,6 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
|
|||||||
}
|
}
|
||||||
swipeFinishTime := time.Now()
|
swipeFinishTime := time.Now()
|
||||||
|
|
||||||
// wait for live video loading
|
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
|
|
||||||
liveRoom, err := vc.getCurrentLiveRoom()
|
liveRoom, err := vc.getCurrentLiveRoom()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "get current live event trackings failed")
|
return errors.Wrap(err, "get current live event trackings failed")
|
||||||
@@ -188,16 +185,15 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
|
|||||||
|
|
||||||
// take screenshot and get screen texts by OCR
|
// take screenshot and get screen texts by OCR
|
||||||
screenResult, err := vc.driverExt.GetScreenResult(
|
screenResult, err := vc.driverExt.GetScreenResult(
|
||||||
WithScreenShotOCR(true), WithScreenShotUpload(true))
|
WithScreenShotOCR(true), WithScreenShotUpload(true), WithScreenShotLiveType(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("OCR GetTexts failed")
|
log.Error().Err(err).Msg("OCR GetTexts failed")
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
liveRoom.LiveType = screenResult.LiveType
|
||||||
screenResult.Live = liveRoom
|
screenResult.Live = liveRoom
|
||||||
|
|
||||||
// TODO: check live type
|
|
||||||
|
|
||||||
// incr live count
|
// incr live count
|
||||||
screenResult.VideoType = "live"
|
screenResult.VideoType = "live"
|
||||||
vc.LiveCount++
|
vc.LiveCount++
|
||||||
|
|||||||
Reference in New Issue
Block a user