mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
Merge pull request #1677 from httprunner/add-expert-test
- introduce expert test for both integration and regression - add TapByUITypes method in step_mobile_ui.go
This commit is contained in:
+2
-11
@@ -547,17 +547,8 @@ func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
|
||||
case ACTION_TapByCV:
|
||||
if imagePath, ok := action.Params.(string); ok {
|
||||
return dExt.TapByCV(imagePath, action.GetOptions()...)
|
||||
}
|
||||
if uiParams, ok := action.Params.([]interface{}); ok {
|
||||
var uiTypes []string
|
||||
for _, uiParam := range uiParams {
|
||||
uiType, ok := uiParam.(string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
uiTypes = append(uiTypes, uiType)
|
||||
}
|
||||
return dExt.TapByUIDetection(uiTypes, action.Options.Options()...)
|
||||
} else if err := dExt.TapByUIDetection(action.GetOptions()...); err == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid %s params: %v", ACTION_TapByCV, action.Params)
|
||||
case ACTION_DoubleTapXY:
|
||||
|
||||
@@ -478,6 +478,7 @@ func (u UIResults) FilterScope(scope AbsScope) (results UIResults) {
|
||||
|
||||
type UIResultMap map[string]UIResults
|
||||
|
||||
// FilterUIResults filters ui icons, the former the uiTypes, the higher the priority
|
||||
func (u UIResultMap) FilterUIResults(uiTypes []string) (uiResults UIResults, err error) {
|
||||
var ok bool
|
||||
for _, uiType := range uiTypes {
|
||||
@@ -512,20 +513,22 @@ func (u UIResults) GetUIResult(options ...ActionOption) (UIResult, error) {
|
||||
return uiResults[idx], nil
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) FindUIResult(uiTypes []string, options ...ActionOption) (point PointF, err error) {
|
||||
screenResult, err := dExt.GetScreenResult(WithScreenShotUITypes(uiTypes...))
|
||||
func (dExt *DriverExt) FindUIResult(options ...ActionOption) (point PointF, err error) {
|
||||
actionOptions := NewActionOptions(options...)
|
||||
|
||||
screenResult, err := dExt.GetScreenResult(options...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
uiResults, err := screenResult.Icons.FilterUIResults(uiTypes)
|
||||
uiResults, err := screenResult.Icons.FilterUIResults(actionOptions.ScreenShotWithUITypes)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
uiResult, err := uiResults.GetUIResult(dExt.ParseActionOptions(options...)...)
|
||||
point = uiResult.Center()
|
||||
|
||||
log.Info().Interface("text", uiTypes).
|
||||
log.Info().Interface("text", actionOptions.ScreenShotWithUITypes).
|
||||
Interface("point", point).Msg("FindUIResult success")
|
||||
return
|
||||
}
|
||||
|
||||
+2
-2
@@ -49,10 +49,10 @@ func (dExt *DriverExt) TapByCV(imagePath string, options ...ActionOption) error
|
||||
return dExt.TapAbsXY(point.X, point.Y, options...)
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) TapByUIDetection(uiTypes []string, options ...ActionOption) error {
|
||||
func (dExt *DriverExt) TapByUIDetection(options ...ActionOption) error {
|
||||
actionOptions := NewActionOptions(options...)
|
||||
|
||||
point, err := dExt.FindUIResult(uiTypes, options...)
|
||||
point, err := dExt.FindUIResult(options...)
|
||||
if err != nil {
|
||||
if actionOptions.IgnoreNotFoundError {
|
||||
return nil
|
||||
|
||||
+13
-2
@@ -102,7 +102,7 @@ func (s *StepMobile) Tap(params string, options ...uixt.ActionOption) *StepMobil
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
// Tap taps on the target element by OCR recognition
|
||||
// TapByOCR taps on the target element by OCR recognition
|
||||
func (s *StepMobile) TapByOCR(ocrText string, options ...uixt.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_TapByOCR,
|
||||
@@ -114,7 +114,7 @@ func (s *StepMobile) TapByOCR(ocrText string, options ...uixt.ActionOption) *Ste
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
// Tap taps on the target element by CV recognition
|
||||
// TapByCV taps on the target element by CV recognition
|
||||
func (s *StepMobile) TapByCV(imagePath string, options ...uixt.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_TapByCV,
|
||||
@@ -126,6 +126,17 @@ func (s *StepMobile) TapByCV(imagePath string, options ...uixt.ActionOption) *St
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
// TapByUITypes taps on the target element specified by uiTypes, the higher the uiTypes, the higher the priority
|
||||
func (s *StepMobile) TapByUITypes(options ...uixt.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_TapByCV,
|
||||
Options: uixt.NewActionOptions(options...),
|
||||
}
|
||||
|
||||
s.mobileStep().Actions = append(s.mobileStep().Actions, action)
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
// DoubleTapXY double taps the point {X,Y}, X & Y is percentage of coordinates
|
||||
func (s *StepMobile) DoubleTapXY(x, y float64, options ...uixt.ActionOption) *StepMobile {
|
||||
s.mobileStep().Actions = append(s.mobileStep().Actions, uixt.MobileAction{
|
||||
|
||||
Reference in New Issue
Block a user