mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +08:00
change: dump ocr texts as string in summary
This commit is contained in:
+6
-6
@@ -51,8 +51,8 @@ type DriverExt struct {
|
|||||||
windowSize Size
|
windowSize Size
|
||||||
frame *bytes.Buffer
|
frame *bytes.Buffer
|
||||||
doneMjpegStream chan bool
|
doneMjpegStream chan bool
|
||||||
OCRService IOCRService // used to get texts from image
|
OCRService IOCRService // used to get texts from image
|
||||||
stepScreenShots map[string]OCRTexts // cache screenshot ocr results, key is image path
|
stepScreenShots map[string]string // cache screenshot ocr results, key is image path, value is dumped OCRTexts
|
||||||
|
|
||||||
CVArgs
|
CVArgs
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ func NewDriverExt(device Device, driver WebDriver) (dExt *DriverExt, err error)
|
|||||||
dExt = &DriverExt{
|
dExt = &DriverExt{
|
||||||
Device: device,
|
Device: device,
|
||||||
Driver: driver,
|
Driver: driver,
|
||||||
stepScreenShots: make(map[string]OCRTexts),
|
stepScreenShots: make(map[string]string),
|
||||||
}
|
}
|
||||||
dExt.doneMjpegStream = make(chan bool, 1)
|
dExt.doneMjpegStream = make(chan bool, 1)
|
||||||
|
|
||||||
@@ -160,19 +160,19 @@ func (dExt *DriverExt) saveScreenShot(raw *bytes.Buffer, fileName string) (strin
|
|||||||
return "", errors.Wrap(err, "encode screenshot image failed")
|
return "", errors.Wrap(err, "encode screenshot image failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
dExt.stepScreenShots[screenshotPath] = nil
|
dExt.stepScreenShots[screenshotPath] = ""
|
||||||
log.Info().Str("path", screenshotPath).Msg("save screenshot file success")
|
log.Info().Str("path", screenshotPath).Msg("save screenshot file success")
|
||||||
return screenshotPath, nil
|
return screenshotPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) GetScreenShots() map[string]OCRTexts {
|
func (dExt *DriverExt) GetScreenShots() map[string]string {
|
||||||
defer func() {
|
defer func() {
|
||||||
for key := range dExt.stepScreenShots {
|
for key := range dExt.stepScreenShots {
|
||||||
delete(dExt.stepScreenShots, key)
|
delete(dExt.stepScreenShots, key)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
copied := make(map[string]OCRTexts)
|
copied := make(map[string]string)
|
||||||
for key, value := range dExt.stepScreenShots {
|
for key, value := range dExt.stepScreenShots {
|
||||||
copied[key] = value
|
copied[key] = value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,8 @@ func (dExt *DriverExt) GetScreenTextsByOCR() (texts OCRTexts, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dExt.stepScreenShots[imagePath] = ocrTexts
|
o, _ := json.Marshal(ocrTexts)
|
||||||
|
dExt.stepScreenShots[imagePath] = string(o)
|
||||||
return ocrTexts, nil
|
return ocrTexts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user