mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-26 10:01:28 +08:00
feat: add Init for driver
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0+2412191212
|
||||
v5.0.0+2412191325
|
||||
|
||||
@@ -193,13 +193,6 @@ func (dev *AndroidDevice) Options() (deviceOptions []AndroidDeviceOption) {
|
||||
func (dev *AndroidDevice) Init() error {
|
||||
dev.d.RunShellCommand("ime", "enable", UnicodeImePackageName)
|
||||
dev.d.RunShellCommand("rm", "-r", config.DeviceActionLogFilePath)
|
||||
// Notice: brighten should be executed before unlock
|
||||
// brighten android device screen
|
||||
dev.d.RunShellCommand("input", "keyevent", fmt.Sprintf("%d", KCWakeup))
|
||||
// unlock android device screen
|
||||
dev.d.RunShellCommand("input", "keyevent", fmt.Sprintf("%d", KCMenu))
|
||||
// swipe up to unlock
|
||||
dev.d.RunShellCommand("input", "swipe", "540", "1000", "540", "500")
|
||||
|
||||
if dev.UIA2 {
|
||||
// uiautomator2 server must be started before
|
||||
|
||||
@@ -53,6 +53,17 @@ func newDriverExt(device IDevice, driver IWebDriver, options ...DriverOption) (d
|
||||
return dExt, nil
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) Init() error {
|
||||
// unlock device screen
|
||||
err := dExt.Driver.Unlock()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("unlock device screen failed")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) assertOCR(text, assert string) error {
|
||||
var options []ActionOption
|
||||
options = append(options, WithScreenShotFileName(fmt.Sprintf("assert_ocr_%s", text)))
|
||||
|
||||
@@ -426,6 +426,9 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := driver.Init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.uixtDrivers[device.SerialNumber] = driver
|
||||
}
|
||||
// parse iOS devices config
|
||||
@@ -446,6 +449,9 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := driver.Init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.uixtDrivers[device.UDID] = driver
|
||||
}
|
||||
// parse harmony devices config
|
||||
@@ -466,6 +472,9 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := driver.Init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.uixtDrivers[device.ConnectKey] = driver
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user