fix: unittext

This commit is contained in:
xucong.053
2022-10-11 15:55:20 +08:00
parent 2815d67331
commit a697623ae2
5 changed files with 14 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ func TestIOSDouyinFollowLive(t *testing.T) {
IOS().
TapByOCR("关注", hrp.WithIndex(1)).Sleep(10),
hrp.NewStep("向上滑动 2 次").
IOS().SwipeToTapFromTexts([]string{"理肤泉", "婉宝"}, hrp.WithDirection([]float64{0.6, 0.2, 0.2, 0.2}), hrp.WithIdentifier("click_live")).Sleep(10).
IOS().SwipeToTapTexts([]string{"理肤泉", "婉宝"}, hrp.WithCustomDirection(0.6, 0.2, 0.2, 0.2), hrp.WithIdentifier("click_live")).Sleep(10).
Swipe(0.9, 0.7, 0.9, 0.3, hrp.WithIdentifier("slide_in_live")).Sleep(10).ScreenShot(). // 上划 1 次,等待 10s截图保存
Swipe(0.9, 0.7, 0.9, 0.3, hrp.WithIdentifier("slide_in_live")).Sleep(10).ScreenShot(), // 再上划 1 次,等待 10s截图保存
},

View File

@@ -88,13 +88,20 @@ func WithIndex(index int) ActionOption {
}
}
// WithDirection inputs direction (up, down, left, right, []float64{sx, sy, ex, ey})
func WithDirection(direction interface{}) ActionOption {
// WithDirection inputs direction (up, down, left, right)
func WithDirection(direction string) ActionOption {
return func(o *MobileAction) {
o.Direction = direction
}
}
// WithCustomDirection inputs sx, sy, ex, ey
func WithCustomDirection(sx, sy, ex, ey float64) ActionOption {
return func(o *MobileAction) {
o.Direction = []float64{sx, sy, ex, ey}
}
}
func WithText(text string) ActionOption {
return func(o *MobileAction) {
o.Text = text
@@ -438,7 +445,7 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
if action.Direction != nil {
return dExt.SwipeUntil(action.Direction, findText, foundTextAction, action.MaxRetryTimes)
}
// swipe until live room found
// swipe until found
return dExt.SwipeUntil("up", findText, foundTextAction, action.MaxRetryTimes)
case AppTerminate:
if bundleId, ok := action.Params.(string); ok {

View File

@@ -30,6 +30,7 @@ var (
WithID = uixt.WithID
WithDescription = uixt.WithDescription
WithDirection = uixt.WithDirection
WithCustomDirection = uixt.WithCustomDirection
)
var (

View File

@@ -324,7 +324,7 @@ func (s *StepAndroid) SwipeToTapText(text string, options ...uixt.ActionOption)
return &StepAndroid{step: s.step}
}
func (s *StepAndroid) SwipeToTapFromTexts(texts []string, options ...uixt.ActionOption) *StepAndroid {
func (s *StepAndroid) SwipeToTapTexts(texts []string, options ...uixt.ActionOption) *StepAndroid {
action := uixt.MobileAction{
Method: uixt.ACTION_SwipeToTapText,
Params: texts,

View File

@@ -244,7 +244,7 @@ func (s *StepIOS) SwipeToTapText(text string, options ...uixt.ActionOption) *Ste
return &StepIOS{step: s.step}
}
func (s *StepIOS) SwipeToTapFromTexts(texts []string, options ...uixt.ActionOption) *StepIOS {
func (s *StepIOS) SwipeToTapTexts(texts []string, options ...uixt.ActionOption) *StepIOS {
action := uixt.MobileAction{
Method: uixt.ACTION_SwipeToTapText,
Params: texts,