mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-09 01:17:30 +08:00
tap_cv supports WithDataScope
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v4.3.3.2306151200
|
v4.3.3.2306281303
|
||||||
@@ -203,7 +203,7 @@ func (dExt *DriverExt) FindDetectUIRectInUIKit(uiTypes []string, options ...Data
|
|||||||
return 0, 0, 0, 0, err
|
return 0, 0, 0, 0, err
|
||||||
}
|
}
|
||||||
var rect image.Rectangle
|
var rect image.Rectangle
|
||||||
rect, err = service.FindUI(uiTypes, bufSource.Bytes())
|
rect, err = service.FindUI(uiTypes, bufSource.Bytes(), options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, 0, 0, err
|
return 0, 0, 0, 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-3
@@ -614,15 +614,30 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
|||||||
return fmt.Errorf("invalid %s params: %v", ACTION_TapByOCR, action.Params)
|
return fmt.Errorf("invalid %s params: %v", ACTION_TapByOCR, action.Params)
|
||||||
case ACTION_TapByCV:
|
case ACTION_TapByCV:
|
||||||
if imagePath, ok := action.Params.(string); ok {
|
if imagePath, ok := action.Params.(string); ok {
|
||||||
return dExt.TapByCV(imagePath, WithDataIdentifier(action.Identifier), WithDataIgnoreNotFoundError(action.IgnoreNotFoundError), WithDataIndex(action.Index))
|
return dExt.TapByCV(
|
||||||
|
imagePath,
|
||||||
|
WithDataIdentifier(action.Identifier),
|
||||||
|
WithDataIgnoreNotFoundError(action.IgnoreNotFoundError),
|
||||||
|
WithDataIndex(action.Index),
|
||||||
|
WithDataScope(dExt.getAbsScope(action.Scope[0], action.Scope[1], action.Scope[2], action.Scope[3])),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if uiParams, ok := action.Params.([]interface{}); ok {
|
if uiParams, ok := action.Params.([]interface{}); ok {
|
||||||
var uiTypes []string
|
var uiTypes []string
|
||||||
for _, uiParam := range uiParams {
|
for _, uiParam := range uiParams {
|
||||||
uiType, _ := uiParam.(string)
|
uiType, ok := uiParam.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
uiTypes = append(uiTypes, uiType)
|
uiTypes = append(uiTypes, uiType)
|
||||||
}
|
}
|
||||||
return dExt.TapByUIDetection(uiTypes, WithDataIdentifier(action.Identifier), WithDataIgnoreNotFoundError(action.IgnoreNotFoundError), WithDataIndex(action.Index))
|
return dExt.TapByUIDetection(
|
||||||
|
uiTypes,
|
||||||
|
WithDataIdentifier(action.Identifier),
|
||||||
|
WithDataIgnoreNotFoundError(action.IgnoreNotFoundError),
|
||||||
|
WithDataIndex(action.Index),
|
||||||
|
WithDataScope(dExt.getAbsScope(action.Scope[0], action.Scope[1], action.Scope[2], action.Scope[3])),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("invalid %s params: %v", ACTION_TapByCV, action.Params)
|
return fmt.Errorf("invalid %s params: %v", ACTION_TapByCV, action.Params)
|
||||||
case ACTION_DoubleTapXY:
|
case ACTION_DoubleTapXY:
|
||||||
|
|||||||
@@ -152,15 +152,13 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(uiResult) == 0 {
|
if len(uiResult) == 0 {
|
||||||
err = fmt.Errorf("UI types %v not detected", uiTypes)
|
return image.Rectangle{}, errors.Wrap(code.CVImageNotFoundError,
|
||||||
log.Error().Err(err).Msg("getUIResult failed")
|
fmt.Sprintf("ui types %v not found", uiTypes))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var rects []image.Rectangle
|
var rects []image.Rectangle
|
||||||
for _, box := range uiResult {
|
for _, box := range uiResult {
|
||||||
rect = image.Rectangle{
|
rect = image.Rectangle{
|
||||||
// cvResult.Points 顺序:左上 -> 右上 -> 右下 -> 左下
|
|
||||||
Min: image.Point{
|
Min: image.Point{
|
||||||
X: int(box.Point.X),
|
X: int(box.Point.X),
|
||||||
Y: int(box.Point.Y),
|
Y: int(box.Point.Y),
|
||||||
@@ -182,7 +180,7 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
|
|||||||
|
|
||||||
if len(rects) == 0 {
|
if len(rects) == 0 {
|
||||||
return image.Rectangle{}, errors.Wrap(code.CVImageNotFoundError,
|
return image.Rectangle{}, errors.Wrap(code.CVImageNotFoundError,
|
||||||
fmt.Sprintf("image not found"))
|
fmt.Sprintf("ui found, but out of scope %v", data.Scope))
|
||||||
}
|
}
|
||||||
|
|
||||||
// get index
|
// get index
|
||||||
@@ -197,7 +195,7 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
|
|||||||
// index out of range
|
// index out of range
|
||||||
if idx >= len(rects) {
|
if idx >= len(rects) {
|
||||||
return image.Rectangle{}, errors.Wrap(code.CVImageNotFoundError,
|
return image.Rectangle{}, errors.Wrap(code.CVImageNotFoundError,
|
||||||
fmt.Sprintf("image found, index %d out of range", idx))
|
fmt.Sprintf("ui found, but index %d out of range", idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
return rects[idx], nil
|
return rects[idx], nil
|
||||||
|
|||||||
Reference in New Issue
Block a user