mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
docs: add auto for wcl
This commit is contained in:
@@ -9,6 +9,7 @@ Usage:
|
|||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
--android string run android app
|
--android string run android app
|
||||||
|
--auto auto enter live
|
||||||
-d, --duration int set duration in seconds (default 30)
|
-d, --duration int set duration in seconds (default 30)
|
||||||
-h, --help help for wcl
|
-h, --help help for wcl
|
||||||
-i, --interval int set interval in seconds (default 15)
|
-i, --interval int set interval in seconds (default 15)
|
||||||
@@ -22,7 +23,7 @@ Flags:
|
|||||||
|
|
||||||
|
|
||||||
```bash
|
```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
|
$ 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)
|
wc := NewWorldCupLive(device, matchName, bundleID, duration, interval)
|
||||||
|
|
||||||
|
if auto {
|
||||||
|
wc.EnterLive(bundleID)
|
||||||
|
}
|
||||||
|
|
||||||
wc.Start()
|
wc.Start()
|
||||||
wc.DumpResult()
|
wc.DumpResult()
|
||||||
return nil
|
return nil
|
||||||
@@ -49,6 +54,7 @@ var (
|
|||||||
uuid string
|
uuid string
|
||||||
iosApp string
|
iosApp string
|
||||||
androidApp string
|
androidApp string
|
||||||
|
auto bool
|
||||||
duration int
|
duration int
|
||||||
interval int
|
interval int
|
||||||
logLevel string
|
logLevel string
|
||||||
@@ -61,6 +67,7 @@ func main() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&uuid, "uuid", "u", "", "specify device serial or udid")
|
rootCmd.PersistentFlags().StringVarP(&uuid, "uuid", "u", "", "specify device serial or udid")
|
||||||
rootCmd.PersistentFlags().StringVar(&iosApp, "ios", "", "run ios app")
|
rootCmd.PersistentFlags().StringVar(&iosApp, "ios", "", "run ios app")
|
||||||
rootCmd.PersistentFlags().StringVar(&androidApp, "android", "", "run android 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(&duration, "duration", "d", 30, "set duration in seconds")
|
||||||
rootCmd.PersistentFlags().IntVarP(&interval, "interval", "i", 15, "set interval in seconds")
|
rootCmd.PersistentFlags().IntVarP(&interval, "interval", "i", 15, "set interval in seconds")
|
||||||
rootCmd.PersistentFlags().StringVarP(&matchName, "match-name", "n", "", "specify match name")
|
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
|
duration = 30
|
||||||
}
|
}
|
||||||
|
|
||||||
wc := &WorldCupLive{
|
return &WorldCupLive{
|
||||||
driver: driverExt,
|
driver: driverExt,
|
||||||
file: f,
|
file: f,
|
||||||
resultDir: resultDir,
|
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"),
|
StartTime: startTime.Format("2006-01-02 15:04:05"),
|
||||||
MatchName: matchName,
|
MatchName: matchName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if bundleID != "" {
|
|
||||||
wc.EnterLive(bundleID)
|
|
||||||
}
|
|
||||||
return wc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WorldCupLive) getCurrentLiveTime(utcTime time.Time) error {
|
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")
|
log.Error().Err(err).Msg("launch app failed")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
// 青少年弹窗处理
|
// 青少年弹窗处理
|
||||||
if points, err := wc.driver.GetTextXYs([]string{"青少年模式", "我知道了"}); err == nil {
|
if points, err := wc.driver.GetTextXYs([]string{"青少年模式", "我知道了"}); err == nil {
|
||||||
_ = wc.driver.TapAbsXY(points[1].X, points[1].Y)
|
_ = 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
|
// 进入世界杯 tab
|
||||||
if err = wc.driver.TapByOCR("世界杯"); err != nil {
|
if err = wc.driver.TapByOCR("世界杯"); err != nil {
|
||||||
log.Error().Err(err).Msg("enter 直播中 failed")
|
log.Error().Err(err).Msg("enter 直播中 failed")
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
func TestConvertTimeToSeconds(t *testing.T) {
|
func TestConvertTimeToSeconds(t *testing.T) {
|
||||||
testData := []struct {
|
testData := []struct {
|
||||||
timeStr string
|
timeStr string
|
||||||
@@ -24,14 +30,18 @@ func TestConvertTimeToSeconds(t *testing.T) {
|
|||||||
|
|
||||||
func TestMainIOS(t *testing.T) {
|
func TestMainIOS(t *testing.T) {
|
||||||
device := initIOSDevice(uuid)
|
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.Start()
|
||||||
wc.DumpResult()
|
wc.DumpResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMainAndroid(t *testing.T) {
|
func TestMainAndroid(t *testing.T) {
|
||||||
device := initAndroidDevice(uuid)
|
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.Start()
|
||||||
wc.DumpResult()
|
wc.DumpResult()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
package ios
|
package ios
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
func TestGetDevice(t *testing.T) {
|
func TestGetDevice(t *testing.T) {
|
||||||
device, err := getDevice(udid)
|
device, err := getDevice(udid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user