mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-08 16:41:44 +08:00
feat: tap random point in ocr text rect
This commit is contained in:
@@ -99,6 +99,10 @@ func (o *ActionOptions) Options() []ActionOption {
|
||||
// for tap [x,y] offset
|
||||
options = append(options, WithTapOffset(o.TapOffset[0], o.TapOffset[1]))
|
||||
}
|
||||
if o.TapRandom {
|
||||
// tap random point in OCR/CV rectangle
|
||||
options = append(options, WithTapRandom(true))
|
||||
}
|
||||
if len(o.SwipeOffset) == 4 {
|
||||
// for swipe [fromX, fromY, toX, toY] offset
|
||||
options = append(options, WithSwipeOffset(
|
||||
|
||||
@@ -217,6 +217,7 @@ type ScreenFilterOptions struct {
|
||||
|
||||
Regex bool `json:"regex,omitempty" yaml:"regex,omitempty"` // use regex to match text
|
||||
TapOffset []int `json:"tap_offset,omitempty" yaml:"tap_offset,omitempty"` // tap with point offset
|
||||
TapRandom bool `json:"tap_random,omitempty" yaml:"tap_random,omitempty"` // tap random point in text/image rectangle
|
||||
SwipeOffset []int `json:"swipe_offset,omitempty" yaml:"swipe_offset,omitempty"` // swipe with direction offset
|
||||
OffsetRandomRange []int `json:"offset_random_range,omitempty" yaml:"offset_random_range,omitempty"` // set random range [min, max] for tap/swipe points
|
||||
Index int `json:"index,omitempty" yaml:"index,omitempty"` // index of the target element
|
||||
@@ -247,6 +248,14 @@ func WithTapOffset(offsetX, offsetY int) ActionOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithTapRandom is used with TapByOCR and TapByCV
|
||||
// when set true, tap random point in text/image rectangle
|
||||
func WithTapRandom(tapRandom bool) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.TapRandom = tapRandom
|
||||
}
|
||||
}
|
||||
|
||||
func WithRegex(regex bool) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.Regex = regex
|
||||
|
||||
Reference in New Issue
Block a user