mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 17:29:56 +08:00
Merge branch 'dev-v4.3' of https://github.com/httprunner/httprunner into dev-v4.3
This commit is contained in:
@@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -112,6 +112,32 @@ func (s *StepAndroid) StopRecording() *StepAndroid {
|
||||
return &StepAndroid{step: s.step}
|
||||
}
|
||||
|
||||
// TapXY taps the point {X,Y}, X & Y is percentage of coordinates
|
||||
func (s *StepAndroid) TapXY(x, y float64, options ...uixt.ActionOption) *StepAndroid {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_TapXY,
|
||||
Params: []float64{x, y},
|
||||
}
|
||||
for _, option := range options {
|
||||
option(&action)
|
||||
}
|
||||
s.step.Android.Actions = append(s.step.Android.Actions, action)
|
||||
return &StepAndroid{step: s.step}
|
||||
}
|
||||
|
||||
// TapAbsXY taps the point {X,Y}, X & Y is absolute coordinates
|
||||
func (s *StepAndroid) TapAbsXY(x, y float64, options ...uixt.ActionOption) *StepAndroid {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_TapAbsXY,
|
||||
Params: []float64{x, y},
|
||||
}
|
||||
for _, option := range options {
|
||||
option(&action)
|
||||
}
|
||||
s.step.Android.Actions = append(s.step.Android.Actions, action)
|
||||
return &StepAndroid{step: s.step}
|
||||
}
|
||||
|
||||
func (s *StepAndroid) Tap(params interface{}) *StepAndroid {
|
||||
s.step.Android.Actions = append(s.step.Android.Actions, uixt.MobileAction{
|
||||
Method: uixt.ACTION_Tap,
|
||||
@@ -440,6 +466,13 @@ func runStepAndroid(s *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
}
|
||||
screenshots := make([]string, 0)
|
||||
|
||||
// override step variables
|
||||
stepVariables, err := s.MergeStepVariables(step.Variables)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
parser := s.GetParser()
|
||||
|
||||
// init uiaClient driver
|
||||
uiaClient, err := s.hrpRunner.initUIClient(&step.Android.AndroidDevice)
|
||||
if err != nil {
|
||||
@@ -485,6 +518,9 @@ func runStepAndroid(s *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
|
||||
// run actions
|
||||
for _, action := range actions {
|
||||
if action.Params, err = parser.Parse(action.Params, stepVariables); err != nil {
|
||||
return stepResult, errors.Wrap(err, "parse action params failed")
|
||||
}
|
||||
if err := uiaClient.DoAction(action); err != nil {
|
||||
return stepResult, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user