use of com.seleniumtests.util.video.VideoRecorder in project seleniumRobot by bhecquet.
the class SeleniumRobotTestListener method logLastStep.
/**
* On test end, will take a snap shot and store it
*/
private void logLastStep(ITestResult testResult) {
// finalize manual steps if we use this mode
try {
TestTasks.addStep(null);
} catch (ConfigurationException e) {
// no problem as it's to close the previous manual step
}
TestStep tearDownStep = new TestStep(TestStepManager.LAST_STEP_NAME, testResult, new ArrayList<>(), true);
scenarioLogger.logTestInfo(TestStepManager.LAST_STATE_NAME, new MultipleInfo(TestStepManager.LAST_STATE_NAME));
// add step to video
VideoRecorder videoRecorder = WebUIDriver.getThreadVideoRecorder();
if (videoRecorder != null) {
CustomEventFiringWebDriver.displayStepOnScreen(tearDownStep.getName(), SeleniumTestsContextManager.getThreadContext().getRunMode(), SeleniumTestsContextManager.getThreadContext().getSeleniumGridConnector(), videoRecorder);
}
TestStepManager.setCurrentRootTestStep(tearDownStep);
if (testResult.isSuccess()) {
scenarioLogger.log("Test is OK");
} else if (testResult.getStatus() == ITestResult.FAILURE) {
// issue #289: allow retry in case SO_TIMEOUT is raised
if (SeleniumTestsContextManager.getThreadContext().getRunMode() != DriverMode.LOCAL && testResult.getThrowable() != null && testResult.getThrowable() instanceof WebDriverException && testResult.getThrowable().getMessage().contains("SO_TIMEOUT")) {
logger.info("Test is retried due to SO_TIMEOUT");
increaseMaxRetry();
}
String error = testResult.getThrowable() != null ? ExceptionUtility.getExceptionMessage(testResult.getThrowable()) : "no error found";
scenarioLogger.log("Test is KO with error: " + error);
} else {
scenarioLogger.log("Test has not started or has been skipped");
}
logThrowableToTestEndStep(testResult);
WebUIDriver.logFinalDriversState(testResult);
tearDownStep.updateDuration();
TestStepManager.logTestStep(tearDownStep);
}
use of com.seleniumtests.util.video.VideoRecorder in project seleniumRobot by bhecquet.
the class TestVideoRecorder method testVideoRecording.
/**
* check file is created
* @throws IOException
*/
@Test(groups = "it")
public void testVideoRecording() throws IOException {
VideoRecorder recorder = new VideoRecorder(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()), "testFile.avi");
recorder.start();
// check JFrame is displayed
Assert.assertNotNull(recorder.getLabel());
Assert.assertEquals(recorder.getLabel().getText(), "Starting");
Assert.assertTrue(recorder.getWindow().isShowing());
Assert.assertNotNull(recorder.getWindow());
WaitHelper.waitForSeconds(2);
File recorded = recorder.stop();
Assert.assertTrue("testFile.avi".equals(recorded.getName()));
Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), "testFile.avi").toFile().exists());
Assert.assertEquals(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()).listFiles().length, 1);
// check JFrame is reset
Assert.assertFalse(recorder.getWindow().isShowing());
}
Aggregations