mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-08 01:09:44 +08:00
feat: add Init for driver
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user