mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-06 20:32:44 +08:00
docs: add auto for wcl
This commit is contained in:
@@ -9,6 +9,7 @@ Usage:
|
||||
|
||||
Flags:
|
||||
--android string run android app
|
||||
--auto auto enter live
|
||||
-d, --duration int set duration in seconds (default 30)
|
||||
-h, --help help for wcl
|
||||
-i, --interval int set interval in seconds (default 15)
|
||||
@@ -22,7 +23,7 @@ Flags:
|
||||
|
||||
|
||||
```bash
|
||||
$ wcl -n "法国vs丹麦" --android com.ss.android.ugc.aweme -d 300 -i 15 -u caf0cd51
|
||||
$ wcl -n "比利时vs摩洛哥" --android com.ss.android.ugc.aweme -d 300 -i 15 -u caf0cd51
|
||||
$ wcl -n "比利时vs摩洛哥" --ios com.ss.iphone.ugc.Aweme -d 300 -i 15 -p sys_cpu,sys_mem,sys_disk,sys_net,fps,network,gpu -u 00008030-000438191421802E
|
||||
```
|
||||
|
||||
|
||||
@@ -39,6 +39,11 @@ var rootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
wc := NewWorldCupLive(device, matchName, bundleID, duration, interval)
|
||||
|
||||
if auto {
|
||||
wc.EnterLive(bundleID)
|
||||
}
|
||||
|
||||
wc.Start()
|
||||
wc.DumpResult()
|
||||
return nil
|
||||
@@ -49,6 +54,7 @@ var (
|
||||
uuid string
|
||||
iosApp string
|
||||
androidApp string
|
||||
auto bool
|
||||
duration int
|
||||
interval int
|
||||
logLevel string
|
||||
@@ -61,6 +67,7 @@ func main() {
|
||||
rootCmd.PersistentFlags().StringVarP(&uuid, "uuid", "u", "", "specify device serial or udid")
|
||||
rootCmd.PersistentFlags().StringVar(&iosApp, "ios", "", "run ios app")
|
||||
rootCmd.PersistentFlags().StringVar(&androidApp, "android", "", "run android app")
|
||||
rootCmd.PersistentFlags().BoolVar(&auto, "auto", false, "auto enter live")
|
||||
rootCmd.PersistentFlags().IntVarP(&duration, "duration", "d", 30, "set duration in seconds")
|
||||
rootCmd.PersistentFlags().IntVarP(&interval, "interval", "i", 15, "set interval in seconds")
|
||||
rootCmd.PersistentFlags().StringVarP(&matchName, "match-name", "n", "", "specify match name")
|
||||
|
||||
@@ -133,7 +133,7 @@ func NewWorldCupLive(device uixt.Device, matchName, bundleID string, duration, i
|
||||
duration = 30
|
||||
}
|
||||
|
||||
wc := &WorldCupLive{
|
||||
return &WorldCupLive{
|
||||
driver: driverExt,
|
||||
file: f,
|
||||
resultDir: resultDir,
|
||||
@@ -144,11 +144,6 @@ func NewWorldCupLive(device uixt.Device, matchName, bundleID string, duration, i
|
||||
StartTime: startTime.Format("2006-01-02 15:04:05"),
|
||||
MatchName: matchName,
|
||||
}
|
||||
|
||||
if bundleID != "" {
|
||||
wc.EnterLive(bundleID)
|
||||
}
|
||||
return wc
|
||||
}
|
||||
|
||||
func (wc *WorldCupLive) getCurrentLiveTime(utcTime time.Time) error {
|
||||
@@ -198,12 +193,17 @@ func (wc *WorldCupLive) EnterLive(bundleID string) error {
|
||||
log.Error().Err(err).Msg("launch app failed")
|
||||
return err
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
// 青少年弹窗处理
|
||||
if points, err := wc.driver.GetTextXYs([]string{"青少年模式", "我知道了"}); err == nil {
|
||||
_ = wc.driver.TapAbsXY(points[1].X, points[1].Y)
|
||||
}
|
||||
|
||||
if err = wc.driver.SwipeRelative(0.5, 0.1, 0.8, 0.1); err != nil {
|
||||
log.Error().Err(err).Msg("swipe failed")
|
||||
}
|
||||
|
||||
// 进入世界杯 tab
|
||||
if err = wc.driver.TapByOCR("世界杯"); err != nil {
|
||||
log.Error().Err(err).Msg("enter 直播中 failed")
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestConvertTimeToSeconds(t *testing.T) {
|
||||
testData := []struct {
|
||||
timeStr string
|
||||
@@ -24,14 +30,18 @@ func TestConvertTimeToSeconds(t *testing.T) {
|
||||
|
||||
func TestMainIOS(t *testing.T) {
|
||||
device := initIOSDevice(uuid)
|
||||
wc := NewWorldCupLive(device, "", "com.ss.iphone.ugc.Aweme", 30, 10)
|
||||
bundleID := "com.ss.iphone.ugc.Aweme"
|
||||
wc := NewWorldCupLive(device, "", bundleID, 30, 10)
|
||||
wc.EnterLive(bundleID)
|
||||
wc.Start()
|
||||
wc.DumpResult()
|
||||
}
|
||||
|
||||
func TestMainAndroid(t *testing.T) {
|
||||
device := initAndroidDevice(uuid)
|
||||
wc := NewWorldCupLive(device, "", "com.ss.android.ugc.aweme", 30, 10)
|
||||
bundleID := "com.ss.android.ugc.aweme"
|
||||
wc := NewWorldCupLive(device, "", bundleID, 30, 10)
|
||||
wc.EnterLive(bundleID)
|
||||
wc.Start()
|
||||
wc.DumpResult()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
package ios
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetDevice(t *testing.T) {
|
||||
device, err := getDevice(udid)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user