/// <summary> /// SignOut /// </summary> public void SignOut(LogOutMethod logoutmethod) { UpdateStatus("SignOut Start"); bool result = true; RecordEvent(DeviceWorkflowMarker.DeviceSignOutBegin); if (logoutmethod.Equals(LogOutMethod.PressSignOut)) { if (JetAdvantageLinkControlHelper.WaitingObjectAppear($"//*[@resource-id='{iManageAppsPackageName}:id/iv_more']", 200, 100)) { result &= LinkUI.Controller.Click($"//*[@resource-id='{iManageAppsPackageName}:id/iv_more']"); result &= LinkUI.Controller.Click(new UiSelector().ResourceId($"{iManageAppsPackageName}:id/action_sign_out")); result &= LinkUI.Controller.Click(new UiSelector().ResourceId($"{iManageAppsPackageName}:id/bt_dialog_left")); } } Thread.Sleep(3000); CheckServerErrorPopup(); try { result &= Device.ControlPanel.WaitForState($".hp-homescreen-folder-view[hp-global-top-view=true]", OmniElementState.Exists, TimeSpan.FromSeconds(10)); result &= Device.ControlPanel.CheckState("#hpid-homescreen-logo-icon", OmniElementState.VisibleCompletely); } catch (Exception ex) { DeviceWorkflowException e = new DeviceWorkflowException($"Sign out failed (omni) {ex.ToString()} :: {_appName}", ex); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SignOut.GetDescription()); throw e; } if (!result) { DeviceWorkflowException e = new DeviceWorkflowException($"SignOut is failed :: {_appName}"); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SignOut.GetDescription()); throw e; } RecordEvent(DeviceWorkflowMarker.DeviceSignOutEnd); UpdateStatus("SignOut Finish"); }
/// <summary> /// SignOut /// </summary> public void SignOut(LogOutMethod logoutmethod) { UpdateStatus("SignOut Start"); string reason = $"Fail to sign out :: {_appName}"; bool result = true; RecordEvent(DeviceWorkflowMarker.DeviceSignOutBegin); UpdateStatus($"logoutmethod :: {logoutmethod}"); if (logoutmethod.Equals(LogOutMethod.PressBackKey)) { while (!JetAdvantageLinkControlHelper.WaitingObjectAppear(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/bt_dialog_right"), 200, 20)) { result &= LinkUI.Controller.PressKey(KeyCode.KEYCODE_BACK); Thread.Sleep(1000); } result &= LinkUI.Controller.Click(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/bt_dialog_left")); } else if (logoutmethod.Equals(LogOutMethod.PressSignOut)) { while (!JetAdvantageLinkControlHelper.WaitingObjectAppear(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/btn_more"), 200, 20)) { result &= LinkUI.Controller.PressKey(KeyCode.KEYCODE_BACK); Thread.Sleep(1000); } result &= LinkUI.Controller.Click(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/btn_more")); result &= LinkUI.Controller.Click(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/action_sign_out")); result &= LinkUI.Controller.Click(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/bt_dialog_left")); } Thread.Sleep(3000); CheckServerErrorPopup(); if (result) { try { result &= Device.ControlPanel.WaitForState($".hp-homescreen-folder-view[hp-global-top-view=true]", OmniElementState.Exists, TimeSpan.FromSeconds(10)); result &= Device.ControlPanel.CheckState("#hpid-homescreen-logo-icon", OmniElementState.VisibleCompletely); } catch (Exception ex) { DeviceWorkflowException e = new DeviceWorkflowException($"Fail to sign out - Fail to return the home screen after sign out {ex.Message} :: {_appName}", ex); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SignOut.GetDescription()); throw e; } } else { reason = $"Fail to sign out - Can not press sign out on the app :: {_appName}"; } if (!result) { DeviceWorkflowException e = new DeviceWorkflowException(reason); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SignOut.GetDescription()); throw e; } RecordEvent(DeviceWorkflowMarker.DeviceSignOutEnd); UpdateStatus("SignOut Finish"); }