mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 06:19:34 +08:00
Merge pull request #1486 from httprunner/dev-v4.3-bugfix
fix: update action interface of Android automation
This commit is contained in:
@@ -138,11 +138,16 @@ func (s *StepAndroid) TapAbsXY(x, y float64, options ...uixt.ActionOption) *Step
|
|||||||
return &StepAndroid{step: s.step}
|
return &StepAndroid{step: s.step}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepAndroid) Tap(params interface{}) *StepAndroid {
|
// Tap taps on the target element
|
||||||
s.step.Android.Actions = append(s.step.Android.Actions, uixt.MobileAction{
|
func (s *StepAndroid) Tap(params string, options ...uixt.ActionOption) *StepAndroid {
|
||||||
|
action := uixt.MobileAction{
|
||||||
Method: uixt.ACTION_Tap,
|
Method: uixt.ACTION_Tap,
|
||||||
Params: params,
|
Params: params,
|
||||||
})
|
}
|
||||||
|
for _, option := range options {
|
||||||
|
option(&action)
|
||||||
|
}
|
||||||
|
s.step.Android.Actions = append(s.step.Android.Actions, action)
|
||||||
return &StepAndroid{step: s.step}
|
return &StepAndroid{step: s.step}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,11 +249,36 @@ func (s *StepAndroid) SwipeRight(options ...uixt.ActionOption) *StepAndroid {
|
|||||||
return &StepAndroid{step: s.step}
|
return &StepAndroid{step: s.step}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepAndroid) Input(text string) *StepAndroid {
|
func (s *StepAndroid) Input(text string, options ...uixt.ActionOption) *StepAndroid {
|
||||||
s.step.Android.Actions = append(s.step.Android.Actions, uixt.MobileAction{
|
action := uixt.MobileAction{
|
||||||
Method: uixt.ACTION_Input,
|
Method: uixt.ACTION_Input,
|
||||||
Params: text,
|
Params: text,
|
||||||
})
|
}
|
||||||
|
for _, option := range options {
|
||||||
|
option(&action)
|
||||||
|
}
|
||||||
|
s.step.Android.Actions = append(s.step.Android.Actions, action)
|
||||||
|
return &StepAndroid{step: s.step}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Times specify running times for run last action
|
||||||
|
func (s *StepAndroid) Times(n int) *StepAndroid {
|
||||||
|
if n <= 0 {
|
||||||
|
log.Warn().Int("n", n).Msg("times should be positive, set to 1")
|
||||||
|
n = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
actionsTotal := len(s.step.Android.Actions)
|
||||||
|
if actionsTotal == 0 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// actionsTotal >=1 && n >= 1
|
||||||
|
lastAction := s.step.Android.Actions[actionsTotal-1 : actionsTotal][0]
|
||||||
|
for i := 0; i < n-1; i++ {
|
||||||
|
// duplicate last action n-1 times
|
||||||
|
s.step.Android.Actions = append(s.step.Android.Actions, lastAction)
|
||||||
|
}
|
||||||
return &StepAndroid{step: s.step}
|
return &StepAndroid{step: s.step}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user