public void ExceptionTest() { // Arrange. const string expectedMessage = "Exception of type 'Sensit.TestSDK.Exceptions.DeviceCommunicationException' was thrown."; // Act var exception = new DeviceCommunicationException(); // Assert Assert.IsNull(exception.InnerException); Assert.AreEqual(expectedMessage, exception.Message); }
/// <summary> /// Do login the LinkApps using ID/PW /// </summary> /// <param name="id">ID for doing login the application</param> /// <param name="pw">PW for doing login the application</param> public void Login(string id, string pw) { int timeOut = LinkUI.Controller.GetTimeout(); bool result = false; DateTime startTime = DateTime.Now; RecordEvent(DeviceWorkflowMarker.AuthenticationBegin); try { result = JetAdvantageLinkControlHelper.WaitingObjectDisappear(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/iv_dots_bg"), 500, 80); if (!result) { DeviceWorkflowException e = new DeviceWorkflowException($"Fail to find progress bar"); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SignIn.GetDescription()); throw e; } Thread.Sleep(TimeSpan.FromSeconds(3)); using (WebviewObject loginPanel = LinkUI.Controller.GetWebView()) { if (loginPanel.IsExist("//*[@name=\"email\"]", TimeSpan.FromSeconds(30))) { RecordEvent(DeviceWorkflowMarker.EnterCredentialsBegin); UpdateStatus($"id = {id}, pwd = {pw}"); result = loginPanel.SetText("//*[@name=\"email\"]", id, false); if (result) { result = loginPanel.SetText("//*[@name=\"password\"]", pw, false); } RecordEvent(DeviceWorkflowMarker.EnterCredentialsEnd); if (result) { result = loginPanel.Click("//*[@id=\"submit\"]"); } if (result) { result = loginPanel.Click("//*[@id=\"main\"]/div[1]/div/span/th-row/th-column[2]/div/div[2]/div/form[1]/th-button/button", TimeSpan.FromSeconds(20)); } } else { result = false; } } } catch (NullReferenceException ex) { DeviceCommunicationException e = new DeviceCommunicationException("Fail to get webview - You need check used hpk file is \"webview debuggable option\" enabled", ex); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.EnvironmentError.GetDescription()); throw e; } if (result) { if (LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{ClioAppsPackageName}:id/buttonClose"))) { CloseDetailPopup(); } CloseAppGuide(); CheckServerErrorPopup(); RecordEvent(DeviceWorkflowMarker.AuthenticationEnd); UpdateStatus($"Sign in completed - {DateTime.Now.Subtract(startTime).TotalSeconds} secs"); LinkUI.Controller.SetTimeout(_inactivityTimeLimit / 1000); //ms => second LinkUI.Controller.SetTimeout(timeOut); } if (!result) { DeviceWorkflowException e = new DeviceWorkflowException($"Fail to log in by ({id}) :: {_appName}"); e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SignIn.GetDescription()); throw e; } RecordEvent(DeviceWorkflowMarker.AppShown); }