refactor: move ios options to pkg/uixt/options

This commit is contained in:
lilong.129
2025-02-06 14:54:10 +08:00
parent 0c5b60b94a
commit 14c81ea142
25 changed files with 203 additions and 186 deletions

View File

@@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
var iosRootCmd = &cobra.Command{
@@ -12,7 +13,7 @@ var iosRootCmd = &cobra.Command{
}
func getDevice(udid string) (*uixt.IOSDevice, error) {
device, err := uixt.NewIOSDevice(uixt.WithUDID(udid))
device, err := uixt.NewIOSDevice(options.WithUDID(udid))
if err != nil {
return nil, err
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/httprunner/httprunner/v5/internal/sdk"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
var installCmd = &cobra.Command{
@@ -29,7 +30,7 @@ var installCmd = &cobra.Command{
return err
}
device, err := uixt.NewIOSDevice(uixt.WithUDID(udid))
device, err := uixt.NewIOSDevice(options.WithUDID(udid))
if err != nil {
fmt.Println(err)
return err

View File

@@ -9,6 +9,7 @@ import (
"github.com/httprunner/httprunner/v5/internal/sdk"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
var uninstallCmd = &cobra.Command{
@@ -33,7 +34,7 @@ var uninstallCmd = &cobra.Command{
return err
}
device, err := uixt.NewIOSDevice(uixt.WithUDID(udid))
device, err := uixt.NewIOSDevice(options.WithUDID(udid))
if err != nil {
fmt.Println(err)
return err

View File

@@ -5,6 +5,7 @@ import (
"github.com/httprunner/httprunner/v5/internal/builtin"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
type IConfig interface {
@@ -117,23 +118,23 @@ func (c *TConfig) SetWebSocket(times, interval, timeout, size int64) *TConfig {
return c
}
func (c *TConfig) SetIOS(options ...uixt.IOSDeviceOption) *TConfig {
wdaOptions := &uixt.IOSDevice{}
for _, option := range options {
option(wdaOptions)
func (c *TConfig) SetIOS(opts ...options.IOSDeviceOption) *TConfig {
iosOptions := options.NewIOSDeviceConfig(opts...)
device := &uixt.IOSDevice{
IOSDeviceConfig: iosOptions,
}
// each device can have its own settings
if wdaOptions.UDID != "" {
c.IOS = append(c.IOS, wdaOptions)
if iosOptions.UDID != "" {
c.IOS = append(c.IOS, device)
return c
}
// device UDID is not specified, settings will be shared
if len(c.IOS) == 0 {
c.IOS = append(c.IOS, wdaOptions)
c.IOS = append(c.IOS, device)
} else {
c.IOS[0] = wdaOptions
c.IOS[0] = device
}
return c
}

View File

@@ -7,6 +7,7 @@ import (
"time"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
var (
@@ -28,7 +29,7 @@ func init() {
}
func launchAppDriver(pkgName string) (driver *uixt.DriverExt, err error) {
device, _ := uixt.NewIOSDevice(uixt.WithUDID(serial))
device, _ := uixt.NewIOSDevice(options.WithUDID(serial))
driver, err = device.NewDriver()
if err != nil {
return nil, err

View File

@@ -7,6 +7,7 @@ import (
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestIOSDouyinFollowLive(t *testing.T) {
@@ -16,9 +17,9 @@ func TestIOSDouyinFollowLive(t *testing.T) {
"app_name": "抖音",
}).
SetIOS(
uixt.WithWDALogOn(true),
uixt.WithWDAPort(8700),
uixt.WithWDAMjpegPort(8800),
options.WithWDALogOn(true),
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").

View File

@@ -7,6 +7,7 @@ import (
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestIOSDouyinLive(t *testing.T) {
@@ -16,9 +17,9 @@ func TestIOSDouyinLive(t *testing.T) {
"app_name": "抖音",
}).
SetIOS(
uixt.WithWDALogOn(true),
uixt.WithWDAPort(8700),
uixt.WithWDAMjpegPort(8800),
options.WithWDALogOn(true),
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").

View File

@@ -7,6 +7,7 @@ import (
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestWDALog(t *testing.T) {
@@ -16,8 +17,9 @@ func TestWDALog(t *testing.T) {
"app_name": "抖音",
}).
SetIOS(
uixt.WithWDALogOn(true),
uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800),
options.WithWDALogOn(true),
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").

View File

@@ -5,6 +5,7 @@ import (
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestAndroidExpertTest(t *testing.T) {
@@ -151,10 +152,10 @@ func TestIOSExpertTest(t *testing.T) {
"app_name": "抖音",
}).
SetIOS(
uixt.WithUDID("$device"),
uixt.WithWDALogOn(true),
uixt.WithWDAPort(8700),
uixt.WithWDAMjpegPort(8800),
options.WithUDID("$device"),
options.WithWDALogOn(true),
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
),
TestSteps: []hrp.IStep{
// 温启动

View File

@@ -16,6 +16,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func convertTimeToSeconds(timeStr string) (int, error) {
@@ -38,9 +39,9 @@ func convertTimeToSeconds(timeStr string) (int, error) {
func initIOSDevice(uuid string) uixt.IDevice {
device, err := uixt.NewIOSDevice(
uixt.WithUDID(uuid),
uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800),
uixt.WithResetHomeOnStartup(false), // not reset home on startup
options.WithUDID(uuid),
options.WithWDAPort(8700), options.WithWDAMjpegPort(8800),
options.WithResetHomeOnStartup(false), // not reset home on startup
)
if err != nil {

View File

@@ -9,6 +9,7 @@ import (
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestConvertTimeToSeconds(t *testing.T) {
@@ -55,10 +56,10 @@ func TestIOSDouyinWorldCupLive(t *testing.T) {
"appBundleID": "com.ss.iphone.ugc.Aweme",
}).
SetIOS(
uixt.WithUDID(uuid),
uixt.WithWDALogOn(true),
uixt.WithWDAPort(8700),
uixt.WithWDAMjpegPort(8800),
options.WithUDID(uuid),
options.WithWDALogOn(true),
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").

View File

@@ -9,12 +9,14 @@ import (
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestIOSDemo(t *testing.T) {
device, err := uixt.NewIOSDevice(
uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800),
uixt.WithResetHomeOnStartup(false), // not reset home on startup
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
options.WithResetHomeOnStartup(false), // not reset home on startup
)
if err != nil {
t.Fatal(err)

View File

@@ -28,6 +28,7 @@ import (
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/internal/builtin"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
const (
@@ -54,62 +55,6 @@ const (
var tunnelManager *tunnel.TunnelManager = nil
type IOSDeviceOption func(*IOSDevice)
func WithUDID(udid string) IOSDeviceOption {
return func(device *IOSDevice) {
device.UDID = udid
}
}
func WithWDAPort(port int) IOSDeviceOption {
return func(device *IOSDevice) {
device.Port = port
}
}
func WithWDAMjpegPort(port int) IOSDeviceOption {
return func(device *IOSDevice) {
device.MjpegPort = port
}
}
func WithWDALogOn(logOn bool) IOSDeviceOption {
return func(device *IOSDevice) {
device.LogOn = logOn
}
}
func WithIOSStub(stub bool) IOSDeviceOption {
return func(device *IOSDevice) {
device.STUB = stub
}
}
func WithResetHomeOnStartup(reset bool) IOSDeviceOption {
return func(device *IOSDevice) {
device.ResetHomeOnStartup = reset
}
}
func WithSnapshotMaxDepth(depth int) IOSDeviceOption {
return func(device *IOSDevice) {
device.SnapshotMaxDepth = depth
}
}
func WithAcceptAlertButtonSelector(selector string) IOSDeviceOption {
return func(device *IOSDevice) {
device.AcceptAlertButtonSelector = selector
}
}
func WithDismissAlertButtonSelector(selector string) IOSDeviceOption {
return func(device *IOSDevice) {
device.DismissAlertButtonSelector = selector
}
}
func GetIOSDevices(udid ...string) (deviceList []ios.DeviceEntry, err error) {
devices, err := ios.ListDevices()
if err != nil {
@@ -145,34 +90,6 @@ func GetIOSDevices(udid ...string) (deviceList []ios.DeviceEntry, err error) {
return deviceList, nil
}
func GetIOSDeviceOptions(dev *IOSDevice) (deviceOptions []IOSDeviceOption) {
if dev.UDID != "" {
deviceOptions = append(deviceOptions, WithUDID(dev.UDID))
}
if dev.Port != 0 {
deviceOptions = append(deviceOptions, WithWDAPort(dev.Port))
}
if dev.MjpegPort != 0 {
deviceOptions = append(deviceOptions, WithWDAMjpegPort(dev.MjpegPort))
}
if dev.LogOn {
deviceOptions = append(deviceOptions, WithWDALogOn(true))
}
if dev.ResetHomeOnStartup {
deviceOptions = append(deviceOptions, WithResetHomeOnStartup(true))
}
if dev.SnapshotMaxDepth != 0 {
deviceOptions = append(deviceOptions, WithSnapshotMaxDepth(dev.SnapshotMaxDepth))
}
if dev.AcceptAlertButtonSelector != "" {
deviceOptions = append(deviceOptions, WithAcceptAlertButtonSelector(dev.AcceptAlertButtonSelector))
}
if dev.DismissAlertButtonSelector != "" {
deviceOptions = append(deviceOptions, WithDismissAlertButtonSelector(dev.DismissAlertButtonSelector))
}
return
}
func StartTunnel(recordsPath string, tunnelInfoPort int, userspaceTUN bool) (err error) {
pm, err := tunnel.NewPairRecordManager(recordsPath)
if err != nil {
@@ -208,8 +125,8 @@ func RebootTunnel() (err error) {
return StartTunnel(os.TempDir(), ios.HttpApiPort(), true)
}
func NewIOSDevice(options ...IOSDeviceOption) (device *IOSDevice, err error) {
device = &IOSDevice{
func NewIOSDevice(opts ...options.IOSDeviceOption) (device *IOSDevice, err error) {
deviceOptions := &options.IOSDeviceConfig{
Port: defaultWDAPort,
MjpegPort: defaultMjpegPort,
SnapshotMaxDepth: snapshotMaxDepth,
@@ -218,32 +135,35 @@ func NewIOSDevice(options ...IOSDeviceOption) (device *IOSDevice, err error) {
// switch to iOS springboard before init WDA session
// avoid getting stuck when some super app is active such as douyin or wexin
ResetHomeOnStartup: true,
listeners: make(map[int]*forward.ConnListener),
}
for _, option := range options {
option(device)
for _, option := range opts {
option(deviceOptions)
}
deviceList, err := GetIOSDevices(device.UDID)
deviceList, err := GetIOSDevices(deviceOptions.UDID)
if err != nil {
return nil, errors.Wrap(code.DeviceConnectionError, err.Error())
}
if device.UDID == "" && len(deviceList) > 1 {
if deviceOptions.UDID == "" && len(deviceList) > 1 {
return nil, errors.Wrap(code.DeviceConnectionError, "more than one device connected, please specify the udid")
}
dev := deviceList[0]
udid := dev.Properties.SerialNumber
if device.UDID == "" {
device.UDID = udid
if deviceOptions.UDID == "" {
deviceOptions.UDID = udid
log.Warn().
Str("udid", udid).
Msg("ios UDID is not specified, select the first one")
}
device.d = dev
device = &IOSDevice{
IOSDeviceConfig: deviceOptions,
listeners: make(map[int]*forward.ConnListener),
d: dev,
}
log.Info().Str("udid", device.UDID).Msg("init ios device")
err = device.Init()
if err != nil {
@@ -254,52 +174,9 @@ func NewIOSDevice(options ...IOSDeviceOption) (device *IOSDevice, err error) {
}
type IOSDevice struct {
*options.IOSDeviceConfig
d ios.DeviceEntry
listeners map[int]*forward.ConnListener
UDID string `json:"udid,omitempty" yaml:"udid,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"` // WDA remote port
MjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"` // WDA remote MJPEG port
STUB bool `json:"stub,omitempty" yaml:"stub,omitempty"` // use stub
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
// switch to iOS springboard before init WDA session
ResetHomeOnStartup bool `json:"reset_home_on_startup,omitempty" yaml:"reset_home_on_startup,omitempty"`
// config appium settings
SnapshotMaxDepth int `json:"snapshot_max_depth,omitempty" yaml:"snapshot_max_depth,omitempty"`
AcceptAlertButtonSelector string `json:"accept_alert_button_selector,omitempty" yaml:"accept_alert_button_selector,omitempty"`
DismissAlertButtonSelector string `json:"dismiss_alert_button_selector,omitempty" yaml:"dismiss_alert_button_selector,omitempty"`
}
func (dev *IOSDevice) Options() (deviceOptions []IOSDeviceOption) {
if dev.UDID != "" {
deviceOptions = append(deviceOptions, WithUDID(dev.UDID))
}
if dev.Port != 0 {
deviceOptions = append(deviceOptions, WithWDAPort(dev.Port))
}
if dev.MjpegPort != 0 {
deviceOptions = append(deviceOptions, WithWDAMjpegPort(dev.MjpegPort))
}
if dev.STUB {
deviceOptions = append(deviceOptions, WithIOSStub(true))
}
if dev.LogOn {
deviceOptions = append(deviceOptions, WithWDALogOn(true))
}
if dev.ResetHomeOnStartup {
deviceOptions = append(deviceOptions, WithResetHomeOnStartup(true))
}
if dev.SnapshotMaxDepth != 0 {
deviceOptions = append(deviceOptions, WithSnapshotMaxDepth(dev.SnapshotMaxDepth))
}
if dev.AcceptAlertButtonSelector != "" {
deviceOptions = append(deviceOptions, WithAcceptAlertButtonSelector(dev.AcceptAlertButtonSelector))
}
if dev.DismissAlertButtonSelector != "" {
deviceOptions = append(deviceOptions, WithDismissAlertButtonSelector(dev.DismissAlertButtonSelector))
}
return
}
type DeviceDetail struct {

View File

@@ -7,6 +7,7 @@ import (
"testing"
"github.com/httprunner/httprunner/v5/internal/builtin"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
var (
@@ -16,7 +17,10 @@ var (
func setupiOSStubDriver(t *testing.T) {
var err error
iOSDevice, err = NewIOSDevice(WithWDAPort(8700), WithWDAMjpegPort(8800), WithIOSStub(false))
iOSDevice, err = NewIOSDevice(
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
options.WithIOSStub(false))
checkErr(t, err)
iOSStubDriver, err = iOSDevice.NewStubDriver()
checkErr(t, err)

View File

@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
"github.com/rs/zerolog/log"
)
@@ -18,7 +19,10 @@ var (
)
func setup(t *testing.T) {
device, err := NewIOSDevice(WithWDAPort(8700), WithWDAMjpegPort(8800), WithWDALogOn(true))
device, err := NewIOSDevice(
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800),
options.WithWDALogOn(true))
if err != nil {
t.Fatal(err)
}
@@ -49,29 +53,36 @@ func TestInstall(t *testing.T) {
}
func TestNewIOSDevice(t *testing.T) {
device, _ := NewIOSDevice(WithWDAPort(8700), WithWDAMjpegPort(8800))
device, _ := NewIOSDevice(
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800))
if device != nil {
t.Log(device)
}
device, _ = NewIOSDevice(WithUDID("xxxx"))
device, _ = NewIOSDevice(options.WithUDID("xxxx"))
if device != nil {
t.Log(device)
}
device, _ = NewIOSDevice(WithWDAPort(8700), WithWDAMjpegPort(8800))
device, _ = NewIOSDevice(
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800))
if device != nil {
t.Log(device)
}
device, _ = NewIOSDevice(WithUDID("xxxx"), WithWDAPort(8700), WithWDAMjpegPort(8800))
device, _ = NewIOSDevice(
options.WithUDID("xxxx"),
options.WithWDAPort(8700),
options.WithWDAMjpegPort(8800))
if device != nil {
t.Log(device)
}
}
func TestIOSDevice_GetPackageInfo(t *testing.T) {
device, err := NewIOSDevice(WithWDAPort(8700))
device, err := NewIOSDevice(options.WithWDAPort(8700))
checkErr(t, err)
appInfo, err := device.GetPackageInfo("com.ss.iphone.ugc.Aweme")
checkErr(t, err)

View File

@@ -0,0 +1 @@
package options

112
pkg/uixt/options/ios.go Normal file
View File

@@ -0,0 +1,112 @@
package options
type IOSDeviceConfig struct {
UDID string `json:"udid,omitempty" yaml:"udid,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"` // WDA remote port
MjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"` // WDA remote MJPEG port
STUB bool `json:"stub,omitempty" yaml:"stub,omitempty"` // use stub
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
// switch to iOS springboard before init WDA session
ResetHomeOnStartup bool `json:"reset_home_on_startup,omitempty" yaml:"reset_home_on_startup,omitempty"`
// config appium settings
SnapshotMaxDepth int `json:"snapshot_max_depth,omitempty" yaml:"snapshot_max_depth,omitempty"`
AcceptAlertButtonSelector string `json:"accept_alert_button_selector,omitempty" yaml:"accept_alert_button_selector,omitempty"`
DismissAlertButtonSelector string `json:"dismiss_alert_button_selector,omitempty" yaml:"dismiss_alert_button_selector,omitempty"`
}
func (dev *IOSDeviceConfig) Options() (deviceOptions []IOSDeviceOption) {
if dev.UDID != "" {
deviceOptions = append(deviceOptions, WithUDID(dev.UDID))
}
if dev.Port != 0 {
deviceOptions = append(deviceOptions, WithWDAPort(dev.Port))
}
if dev.MjpegPort != 0 {
deviceOptions = append(deviceOptions, WithWDAMjpegPort(dev.MjpegPort))
}
if dev.STUB {
deviceOptions = append(deviceOptions, WithIOSStub(true))
}
if dev.LogOn {
deviceOptions = append(deviceOptions, WithWDALogOn(true))
}
if dev.ResetHomeOnStartup {
deviceOptions = append(deviceOptions, WithResetHomeOnStartup(true))
}
if dev.SnapshotMaxDepth != 0 {
deviceOptions = append(deviceOptions, WithSnapshotMaxDepth(dev.SnapshotMaxDepth))
}
if dev.AcceptAlertButtonSelector != "" {
deviceOptions = append(deviceOptions, WithAcceptAlertButtonSelector(dev.AcceptAlertButtonSelector))
}
if dev.DismissAlertButtonSelector != "" {
deviceOptions = append(deviceOptions, WithDismissAlertButtonSelector(dev.DismissAlertButtonSelector))
}
return
}
func NewIOSDeviceConfig(opts ...IOSDeviceOption) *IOSDeviceConfig {
config := &IOSDeviceConfig{}
for _, opt := range opts {
opt(config)
}
return config
}
type IOSDeviceOption func(*IOSDeviceConfig)
func WithUDID(udid string) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.UDID = udid
}
}
func WithWDAPort(port int) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.Port = port
}
}
func WithWDAMjpegPort(port int) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.MjpegPort = port
}
}
func WithWDALogOn(logOn bool) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.LogOn = logOn
}
}
func WithIOSStub(stub bool) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.STUB = stub
}
}
func WithResetHomeOnStartup(reset bool) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.ResetHomeOnStartup = reset
}
}
func WithSnapshotMaxDepth(depth int) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.SnapshotMaxDepth = depth
}
}
func WithAcceptAlertButtonSelector(selector string) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.AcceptAlertButtonSelector = selector
}
}
func WithDismissAlertButtonSelector(selector string) IOSDeviceOption {
return func(device *IOSDeviceConfig) {
device.DismissAlertButtonSelector = selector
}
}

View File

@@ -5,13 +5,13 @@ package hrp
import (
"testing"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
func TestIOSSettingsAction(t *testing.T) {
testCase := &TestCase{
Config: NewConfig("ios ui action on Settings").
SetIOS(uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800)),
SetIOS(options.WithWDAPort(8700), options.WithWDAMjpegPort(8800)),
TestSteps: []IStep{
NewStep("launch Settings").
IOS().Home().Tap("设置").
@@ -50,7 +50,7 @@ func TestIOSSearchApp(t *testing.T) {
func TestIOSAppLaunch(t *testing.T) {
testCase := &TestCase{
Config: NewConfig("启动 & 关闭 App").
SetIOS(uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800)),
SetIOS(options.WithWDAPort(8700), options.WithWDAMjpegPort(8800)),
TestSteps: []IStep{
NewStep("终止今日头条").
IOS().AppTerminate("com.ss.iphone.article.News"),

View File

@@ -25,6 +25,7 @@ import (
"github.com/httprunner/httprunner/v5/internal/json"
"github.com/httprunner/httprunner/v5/pkg/httpstat"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
type HTTPMethod string
@@ -773,11 +774,8 @@ func (s *StepRequest) Android(options ...uixt.AndroidDeviceOption) *StepMobile {
}
// IOS creates a new ios step session
func (s *StepRequest) IOS(options ...uixt.IOSDeviceOption) *StepMobile {
iosOptions := &uixt.IOSDevice{}
for _, option := range options {
option(iosOptions)
}
func (s *StepRequest) IOS(opts ...options.IOSDeviceOption) *StepMobile {
iosOptions := options.NewIOSDeviceConfig(opts...)
return &StepMobile{
StepConfig: s.StepConfig,
IOS: &MobileUI{