mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 03:49:41 +08:00
fix: wait for action done before screenshot
This commit is contained in:
@@ -155,6 +155,9 @@ func extend(driver WebDriver) (dExt *DriverExt, err error) {
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) takeScreenShot() (raw *bytes.Buffer, err error) {
|
||||
// wait for action done
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
// 优先使用 MJPEG 流进行截图,性能最优
|
||||
// 如果 MJPEG 流未开启,则使用 WebDriver 的截图接口
|
||||
if dExt.frame != nil {
|
||||
|
||||
@@ -93,11 +93,15 @@ func (s *veDEMOCRService) FindText(text string, imageBuf []byte, index ...int) (
|
||||
|
||||
ocrResults, err := s.getOCRResult(imageBuf)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("getOCRResult failed")
|
||||
return
|
||||
}
|
||||
|
||||
var rects []image.Rectangle
|
||||
var ocrTexts []string
|
||||
for _, ocrResult := range ocrResults {
|
||||
ocrTexts = append(ocrTexts, ocrResult.Text)
|
||||
|
||||
// not contains text
|
||||
if !strings.Contains(ocrResult.Text, text) {
|
||||
continue
|
||||
@@ -128,7 +132,8 @@ func (s *veDEMOCRService) FindText(text string, imageBuf []byte, index ...int) (
|
||||
}
|
||||
|
||||
if len(rects) == 0 {
|
||||
return image.Rectangle{}, fmt.Errorf("text %s not found", text)
|
||||
return image.Rectangle{},
|
||||
fmt.Errorf("text %s not found in %v", text, ocrTexts)
|
||||
}
|
||||
|
||||
// get index
|
||||
|
||||
@@ -2,7 +2,6 @@ package uixt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
@@ -82,8 +81,6 @@ func (dExt *DriverExt) SwipeUntil(direction string, condition FindCondition, act
|
||||
if err := dExt.SwipeTo(direction); err != nil {
|
||||
log.Error().Err(err).Msgf("swipe %s failed", direction)
|
||||
}
|
||||
// wait for swipe done
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
return fmt.Errorf("swipe %s %d times, match condition failed", direction, maxTimes)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user