mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +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)
|
wd := new(wdaDriver)
|
||||||
|
|
||||||
if wd.defaultConn, err = dev.d.NewConnect(dev.Port, 0); err != nil {
|
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())
|
wd.client = convertToHTTPClient(wd.defaultConn.RawConn())
|
||||||
|
|
||||||
if wd.mjpegUSBConn, err = dev.d.NewConnect(dev.MjpegPort, 0); err != nil {
|
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())
|
wd.mjpegClient = convertToHTTPClient(wd.mjpegUSBConn.RawConn())
|
||||||
|
|
||||||
|
|||||||
@@ -68,15 +68,15 @@ func (s *veDEMOCRService) getOCRResult(imageBuf []byte) ([]OCRResult, error) {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
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)
|
results, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("read response body error: %v", err)
|
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
|
var ocrResult ResponseOCR
|
||||||
err = json.Unmarshal(results, &ocrResult)
|
err = json.Unmarshal(results, &ocrResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -148,6 +148,7 @@ func (dExt *DriverExt) FindTextByOCR(ocrText string) (x, y, width, height float6
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info().Str("ocrText", ocrText).Msgf("FindText success")
|
||||||
x, y, width, height = dExt.MappingToRectInUIKit(rect)
|
x, y, width, height = dExt.MappingToRectInUIKit(rect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package uixt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"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 {
|
if err := dExt.SwipeTo(direction); err != nil {
|
||||||
log.Error().Err(err).Msgf("swipe %s failed", direction)
|
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)
|
return fmt.Errorf("swipe %s %d times, match condition failed", direction, maxTimes)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user