diff --git a/ios/accessibility/accessibility.go b/ios/accessibility/accessibility.go index 5b900cae..89fbfd63 100644 --- a/ios/accessibility/accessibility.go +++ b/ios/accessibility/accessibility.go @@ -14,6 +14,5 @@ func New(device ios.DeviceEntry) (ControlInterface, error) { return ControlInterface{}, err } control := ControlInterface{conn.GlobalChannel()} - err = control.init() return control, err } diff --git a/ios/accessibility/accessibility_control.go b/ios/accessibility/accessibility_control.go index 5ebea008..61cab559 100644 --- a/ios/accessibility/accessibility_control.go +++ b/ios/accessibility/accessibility_control.go @@ -39,7 +39,7 @@ func (a ControlInterface) readhostInspectorNotificationReceived() { } // Init wires up event receivers and gets Info from the device -func (a ControlInterface) init() error { +func (a ControlInterface) Init() error { a.channel.RegisterMethodForRemote("hostInspectorCurrentElementChanged:") a.channel.RegisterMethodForRemote("hostInspectorMonitoredEventTypeChanged:") a.channel.RegisterMethodForRemote("hostAppStateChanged:") @@ -150,6 +150,14 @@ func (a ControlInterface) UpdateAccessibilitySetting(name string, val interface{ log.Info("Setting Updated", resp) } +func (a ControlInterface) ResetToDefaultAccessibilitySettings() error { + err := a.channel.MethodCallAsync("deviceResetToDefaultAccessibilitySettings") + if err != nil { + return err + } + return nil +} + func (a ControlInterface) awaitHostInspectorCurrentElementChanged() map[string]interface{} { msg := a.channel.ReceiveMethodCall("hostInspectorCurrentElementChanged:") log.Info("received hostInspectorCurrentElementChanged") diff --git a/main.go b/main.go index ec24ed8f..ea057420 100644 --- a/main.go +++ b/main.go @@ -117,6 +117,7 @@ Usage: ios runxctest [--xctestrun-file-path=] [--log-output=] [options] ios runwda [--bundleid=] [--testrunnerbundleid=] [--xctestconfig=] [--log-output=] [--arg=]... [--env=]... [options] ios ax [--font=] [options] + ios resetax [options] ios debug [options] [--stop-at-entry] ios fsync (rm [--r] | tree | mkdir) --path= ios fsync (pull | push) --srcPath= --dstPath= @@ -238,6 +239,7 @@ The commands work as following: ios runwda [--bundleid=] [--testrunnerbundleid=] [--xctestconfig=] [--log-output=] [--arg=]... [--env=]...[options] runs WebDriverAgents > specify runtime args and env vars like --env ENV_1=something --env ENV_2=else and --arg ARG1 --arg ARG2 ios ax [--font=] [options] Access accessibility inspector features. + ios resetax [options] Reset accessibility settings to defaults. ios debug [--stop-at-entry] Start debug with lldb ios fsync (rm [--r] | tree | mkdir) --path= Remove | treeview | mkdir in target path. --r used alongside rm will recursively remove all files and directories from target path. ios fsync (pull | push) --srcPath= --dstPath= Pull or Push file from srcPath to dstPath. @@ -1046,6 +1048,12 @@ The commands work as following: return } + b, _ = arguments.Bool("resetax") + if b { + resetAx(device) + return + } + b, _ = arguments.Bool("debug") if b { appPath, _ := arguments.String("") @@ -1771,7 +1779,10 @@ func timeFormat(device ios.DeviceEntry, operation string, force bool) { func startAx(device ios.DeviceEntry, arguments docopt.Opts) { go func() { conn, err := accessibility.New(device) - exitIfError("failed starting ax", err) + exitIfError("failed creating ax service", err) + + err = conn.Init() + exitIfError("failed init ax", err) conn.SwitchToDevice() @@ -1799,6 +1810,14 @@ func startAx(device ios.DeviceEntry, arguments docopt.Opts) { <-c } +func resetAx(device ios.DeviceEntry) { + conn, err := accessibility.New(device) + exitIfError("failed creating ax service", err) + + err = conn.ResetToDefaultAccessibilitySettings() + exitIfError("failed resetting ax", err) +} + func printVersion() { versionMap := map[string]interface{}{ "version": version,