mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 10:49:43 +08:00
fix: screenshot wait for swipe done
This commit is contained in:
@@ -204,12 +204,14 @@ func (dev *IOSDevice) NewUSBDriver(capabilities Capabilities) (driver WebDriver,
|
||||
wd := new(wdaDriver)
|
||||
|
||||
if wd.defaultConn, err = dev.d.NewConnect(dev.Port, 0); err != nil {
|
||||
return nil, fmt.Errorf("create connection: %w", err)
|
||||
return nil, fmt.Errorf("connect port %d failed: %w",
|
||||
dev.Port, err)
|
||||
}
|
||||
wd.client = convertToHTTPClient(wd.defaultConn.RawConn())
|
||||
|
||||
if wd.mjpegUSBConn, err = dev.d.NewConnect(dev.MjpegPort, 0); err != nil {
|
||||
return nil, fmt.Errorf("create connection MJPEG: %w", err)
|
||||
return nil, fmt.Errorf("connect MJPEG port %d failed: %w",
|
||||
dev.MjpegPort, err)
|
||||
}
|
||||
wd.mjpegClient = convertToHTTPClient(wd.mjpegUSBConn.RawConn())
|
||||
|
||||
|
||||
@@ -68,15 +68,15 @@ func (s *veDEMOCRService) getOCRResult(imageBuf []byte) ([]OCRResult, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("unexpected response status code: %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
results, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read response body error: %v", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("unexpected response status code: %d, results: %v", resp.StatusCode, string(results))
|
||||
}
|
||||
|
||||
var ocrResult ResponseOCR
|
||||
err = json.Unmarshal(results, &ocrResult)
|
||||
if err != nil {
|
||||
@@ -148,6 +148,7 @@ func (dExt *DriverExt) FindTextByOCR(ocrText string) (x, y, width, height float6
|
||||
return
|
||||
}
|
||||
|
||||
log.Info().Str("ocrText", ocrText).Msgf("FindText success")
|
||||
x, y, width, height = dExt.MappingToRectInUIKit(rect)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package uixt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
@@ -81,6 +82,8 @@ 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