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