mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix: unittext
This commit is contained in:
@@ -37,7 +37,7 @@ func TestIOSDouyinFollowLive(t *testing.T) {
|
|||||||
IOS().
|
IOS().
|
||||||
TapByOCR("关注", hrp.WithIndex(1)).Sleep(10),
|
TapByOCR("关注", hrp.WithIndex(1)).Sleep(10),
|
||||||
hrp.NewStep("向上滑动 2 次").
|
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,截图保存
|
||||||
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,截图保存
|
||||||
},
|
},
|
||||||
|
|||||||
+10
-3
@@ -88,13 +88,20 @@ func WithIndex(index int) ActionOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDirection inputs direction (up, down, left, right, []float64{sx, sy, ex, ey})
|
// WithDirection inputs direction (up, down, left, right)
|
||||||
func WithDirection(direction interface{}) ActionOption {
|
func WithDirection(direction string) ActionOption {
|
||||||
return func(o *MobileAction) {
|
return func(o *MobileAction) {
|
||||||
o.Direction = direction
|
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 {
|
func WithText(text string) ActionOption {
|
||||||
return func(o *MobileAction) {
|
return func(o *MobileAction) {
|
||||||
o.Text = text
|
o.Text = text
|
||||||
@@ -438,7 +445,7 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
|||||||
if action.Direction != nil {
|
if action.Direction != nil {
|
||||||
return dExt.SwipeUntil(action.Direction, findText, foundTextAction, action.MaxRetryTimes)
|
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)
|
return dExt.SwipeUntil("up", findText, foundTextAction, action.MaxRetryTimes)
|
||||||
case AppTerminate:
|
case AppTerminate:
|
||||||
if bundleId, ok := action.Params.(string); ok {
|
if bundleId, ok := action.Params.(string); ok {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ var (
|
|||||||
WithID = uixt.WithID
|
WithID = uixt.WithID
|
||||||
WithDescription = uixt.WithDescription
|
WithDescription = uixt.WithDescription
|
||||||
WithDirection = uixt.WithDirection
|
WithDirection = uixt.WithDirection
|
||||||
|
WithCustomDirection = uixt.WithCustomDirection
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ func (s *StepAndroid) SwipeToTapText(text string, options ...uixt.ActionOption)
|
|||||||
return &StepAndroid{step: s.step}
|
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{
|
action := uixt.MobileAction{
|
||||||
Method: uixt.ACTION_SwipeToTapText,
|
Method: uixt.ACTION_SwipeToTapText,
|
||||||
Params: texts,
|
Params: texts,
|
||||||
|
|||||||
+1
-1
@@ -244,7 +244,7 @@ func (s *StepIOS) SwipeToTapText(text string, options ...uixt.ActionOption) *Ste
|
|||||||
return &StepIOS{step: s.step}
|
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{
|
action := uixt.MobileAction{
|
||||||
Method: uixt.ACTION_SwipeToTapText,
|
Method: uixt.ACTION_SwipeToTapText,
|
||||||
Params: texts,
|
Params: texts,
|
||||||
|
|||||||
Reference in New Issue
Block a user