mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +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
|
||||
}
|
||||
var rect image.Rectangle
|
||||
rect, err = service.FindUI(uiTypes, bufSource.Bytes())
|
||||
rect, err = service.FindUI(uiTypes, bufSource.Bytes(), options...)
|
||||
if err != nil {
|
||||
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)
|
||||
case ACTION_TapByCV:
|
||||
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 {
|
||||
var uiTypes []string
|
||||
for _, uiParam := range uiParams {
|
||||
uiType, _ := uiParam.(string)
|
||||
uiType, ok := uiParam.(string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
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)
|
||||
case ACTION_DoubleTapXY:
|
||||
|
||||
@@ -152,15 +152,13 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
|
||||
}
|
||||
}
|
||||
if len(uiResult) == 0 {
|
||||
err = fmt.Errorf("UI types %v not detected", uiTypes)
|
||||
log.Error().Err(err).Msg("getUIResult failed")
|
||||
return
|
||||
return image.Rectangle{}, errors.Wrap(code.CVImageNotFoundError,
|
||||
fmt.Sprintf("ui types %v not found", uiTypes))
|
||||
}
|
||||
|
||||
var rects []image.Rectangle
|
||||
for _, box := range uiResult {
|
||||
rect = image.Rectangle{
|
||||
// cvResult.Points 顺序:左上 -> 右上 -> 右下 -> 左下
|
||||
Min: image.Point{
|
||||
X: int(box.Point.X),
|
||||
Y: int(box.Point.Y),
|
||||
@@ -182,7 +180,7 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
|
||||
|
||||
if len(rects) == 0 {
|
||||
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
|
||||
@@ -197,7 +195,7 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
|
||||
// index out of range
|
||||
if idx >= len(rects) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user