diff --git a/hrp/internal/code/code.go b/hrp/internal/code/code.go index fb774376..4687bc96 100644 --- a/hrp/internal/code/code.go +++ b/hrp/internal/code/code.go @@ -135,7 +135,7 @@ var errorsMap = map[error]int{ } func IsErrorPredefined(err error) bool { - _, ok := errorsMap[err] + _, ok := errorsMap[errors.Cause(err)] return ok } diff --git a/hrp/pkg/uixt/ocr_vedem.go b/hrp/pkg/uixt/ocr_vedem.go index 1bae01ad..3f456045 100644 --- a/hrp/pkg/uixt/ocr_vedem.go +++ b/hrp/pkg/uixt/ocr_vedem.go @@ -170,7 +170,7 @@ func (s *veDEMOCRService) FindText(text string, imageBuf []byte, options ...Data Y: int(ocrResult.Points[2].Y), }, } - if rect.Min.X > data.Scope[0] && rect.Max.X < data.Scope[2] && rect.Min.Y > data.Scope[1] && rect.Max.Y < data.Scope[3] { + if rect.Min.X >= data.Scope[0] && rect.Max.X <= data.Scope[2] && rect.Min.Y >= data.Scope[1] && rect.Max.Y <= data.Scope[3] { ocrTexts = append(ocrTexts, ocrResult.Text) // not contains text diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index 3a0cd143..3bf934cd 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -356,6 +356,9 @@ func (s *StepMobile) Name() string { } func (s *StepMobile) Type() StepType { + if s.step.Android != nil { + return stepTypeAndroid + } return stepTypeIOS } @@ -548,21 +551,6 @@ func (r *HRPRunner) initUIClient(uuid string, osType string) (client *uixt.Drive } func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err error) { - stepResult = &StepResult{ - Name: step.Name, - StepType: stepTypeIOS, - Success: false, - ContentSize: 0, - } - screenshots := make([]string, 0) - - // merge step variables with session variables - stepVariables, err := s.ParseStepVariables(step.Variables) - if err != nil { - err = errors.Wrap(err, "parse step variables failed") - return - } - var osType string var mobileStep *MobileStep if step.IOS != nil { @@ -575,6 +563,21 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err mobileStep = step.Android } + stepResult = &StepResult{ + Name: step.Name, + StepType: StepType(osType), + Success: false, + ContentSize: 0, + } + screenshots := make([]string, 0) + + // merge step variables with session variables + stepVariables, err := s.ParseStepVariables(step.Variables) + if err != nil { + err = errors.Wrap(err, "parse step variables failed") + return + } + // init wda/uia driver uiDriver, err := s.caseRunner.hrpRunner.initUIClient(mobileStep.Serial, osType) if err != nil {