refactor: android ui automation

This commit is contained in:
xucong053
2022-09-28 13:46:34 +08:00
parent fe41b20828
commit dd9cf7dc6e
13 changed files with 1912 additions and 1772 deletions

View File

@@ -237,6 +237,11 @@ func (dExt *DriverExt) FindUIElement(param string) (ele WebElement, err error) {
selector = BySelector{
XPath: param,
}
} else if strings.HasPrefix(param, "com.") {
// name
selector = BySelector{
ResourceIdID: param,
}
} else {
// name
selector = BySelector{
@@ -473,18 +478,13 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
dExt.ScreenShots = append(dExt.ScreenShots, screenshotPath)
return err
case CtlStartCamera:
// start camera, alias for app_launch com.apple.camera
return dExt.Driver.AppLaunch("com.apple.camera")
return dExt.Driver.StartCamera()
case CtlStopCamera:
// stop camera, alias for app_terminate com.apple.camera
success, err := dExt.Driver.AppTerminate("com.apple.camera")
if err != nil {
return errors.Wrap(err, "failed to terminate camera")
}
if !success {
log.Warn().Msg("camera was not running")
}
return nil
return dExt.Driver.StopCamera()
case RecordStart:
return dExt.Driver.StartRecording()
case RecordStop:
return dExt.Driver.StopRecording()
}
return nil
}