mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
feat: 新增oppo手动启动一次settings
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
|
||||||
)
|
)
|
||||||
@@ -157,6 +158,20 @@ type AndroidDevice struct {
|
|||||||
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"`
|
IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dev *AndroidDevice) Init() error {
|
||||||
|
brand, err := dev.d.Brand()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to init android device. brand is null %v", err)
|
||||||
|
}
|
||||||
|
if strings.ToLower(brand) == "huawei" {
|
||||||
|
// 启动一次io.appium.settings。防止oppo设备上切换输入法失败
|
||||||
|
myexec.RunCommand("adb", "-s", dev.SerialNumber, "shell",
|
||||||
|
"monkey", "-p", "io.appium.settings", "-c", "android.intent.category.LAUNCHER", "1")
|
||||||
|
}
|
||||||
|
myexec.RunCommand("adb", "-s", dev.SerialNumber, "shell", "rm", "-r", env.DeviceActionLogFilePath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (dev *AndroidDevice) UUID() string {
|
func (dev *AndroidDevice) UUID() string {
|
||||||
return dev.SerialNumber
|
return dev.SerialNumber
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,6 +468,7 @@ func WithDriverPlugin(plugin funplugin.IPlugin) DriverOption {
|
|||||||
|
|
||||||
// current implemeted device: IOSDevice, AndroidDevice
|
// current implemeted device: IOSDevice, AndroidDevice
|
||||||
type Device interface {
|
type Device interface {
|
||||||
|
Init() error // init android device
|
||||||
UUID() string // ios udid or android serial
|
UUID() string // ios udid or android serial
|
||||||
LogEnabled() bool
|
LogEnabled() bool
|
||||||
NewDriver(...DriverOption) (driverExt *DriverExt, err error)
|
NewDriver(...DriverOption) (driverExt *DriverExt, err error)
|
||||||
|
|||||||
@@ -295,6 +295,10 @@ type IOSDevice struct {
|
|||||||
pcapFile string // saved pcap file path
|
pcapFile string // saved pcap file path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dev *IOSDevice) Init() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (dev *IOSDevice) UUID() string {
|
func (dev *IOSDevice) UUID() string {
|
||||||
return dev.UDID
|
return dev.UDID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/httprunner/funplugin"
|
"github.com/httprunner/funplugin"
|
||||||
"github.com/httprunner/funplugin/myexec"
|
|
||||||
"github.com/jinzhu/copier"
|
"github.com/jinzhu/copier"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@@ -26,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
@@ -437,11 +435,15 @@ func (r *CaseRunner) parseConfig() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init iOS device failed")
|
return errors.Wrap(err, "init iOS device failed")
|
||||||
}
|
}
|
||||||
|
if err := device.Init(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init iOS WDA client failed")
|
return errors.Wrap(err, "init iOS WDA client failed")
|
||||||
}
|
}
|
||||||
r.uiClients[device.UDID] = client
|
r.uiClients[device.UDID] = client
|
||||||
|
|
||||||
}
|
}
|
||||||
for _, androidDeviceConfig := range r.parsedConfig.Android {
|
for _, androidDeviceConfig := range r.parsedConfig.Android {
|
||||||
if androidDeviceConfig.SerialNumber != "" {
|
if androidDeviceConfig.SerialNumber != "" {
|
||||||
@@ -456,11 +458,15 @@ func (r *CaseRunner) parseConfig() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init Android device failed")
|
return errors.Wrap(err, "init Android device failed")
|
||||||
}
|
}
|
||||||
|
if err := device.Init(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init Android client failed")
|
return errors.Wrap(err, "init Android client failed")
|
||||||
}
|
}
|
||||||
r.uiClients[device.SerialNumber] = client
|
r.uiClients[device.SerialNumber] = client
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -525,11 +531,6 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
|||||||
config := r.caseRunner.testCase.Config
|
config := r.caseRunner.testCase.Config
|
||||||
log.Info().Str("testcase", config.Name).Msg("run testcase start")
|
log.Info().Str("testcase", config.Name).Msg("run testcase start")
|
||||||
|
|
||||||
// 安卓系统删除打点日志文件
|
|
||||||
if r.caseRunner.testCase.Config.Android != nil {
|
|
||||||
myexec.RunCommand("adb", "-s", r.caseRunner.testCase.Config.Android[0].SerialNumber, "shell", "rm", "-r", env.DeviceActionLogFilePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// update config variables with given variables
|
// update config variables with given variables
|
||||||
r.InitWithParameters(givenVars)
|
r.InitWithParameters(givenVars)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user