public void StartRecording(ScreenRecorder screenRecorder, int tryCount = 5) { try { int tryIndex = 1; do { _logger.Info($"Try Count {tryIndex}: The status of recorder is " + screenRecorder.Status); if (screenRecorder.Status == ScreenRecordStatus.Fail || (screenRecorder.Status == ScreenRecordStatus.Idle && tryIndex > 1)) { _logger.Info($"Try Count {tryIndex}: Re-recording"); screenRecorder = ScreenRecorder.CreateRecorder(screenRecorder.videoPath); screenRecorder.StartRecording(); } else if (screenRecorder.Status != ScreenRecordStatus.Recording) { _logger.Info($"Try Count {tryIndex}: Start recording"); screenRecorder.StartRecording(); } _logger.Info($"Try Count {tryIndex}: Now recorder status is " + recorder.Status); tryIndex++; } while (tryIndex <= tryCount && screenRecorder.Status != ScreenRecordStatus.Recording); } catch (Exception ex) { _logger.Info("Exception occurs when start recording."); _logger.Info(ex.Message); } }
public void EditorEnterText() { var screenRecorder = ScreenRecorder.CreateRecorder(@"D:\Improvement\PrepareForTestReportTeacher\NotepadTest\TestResults\screenRecorder.mp4"); _logger.Info("start"); screenRecorder.StartRecording(screenRecorder, 2); // Type mixed text and apply shift modifier to 7890_ to generate corresponding symbols Thread.Sleep(TimeSpan.FromSeconds(2)); editBox.SendKeys("abcdeABCDE 12345" + Keys.Shift + "7890-" + Keys.Shift + @"!@#$%"); WinDriverUtil.ShotScreen(WinDriverUtil.DesktopSession, @"D:\Improvement\PrepareForTestReportTeacher\NotepadTest\TestResults\screen.png"); Assert.AreEqual(@"abcdeABCDE 12345&*()_!@#$%", editBox.Text); _logger.Info("end recordering"); screenRecorder.EndRecording(); _logger.Info("end test"); }