use of com.seleniumtests.reporter.info.VideoLinkInfo in project seleniumRobot by bhecquet.
the class SeleniumRobotTestPlan method finishTestMethod.
/**
* According to TestNG doc, this method will be executed after the \@AfterMethod inside test classes
* #issue 136: This will close any remaining browser for this thread and forbid user to create a new driver in other \@AfterXXX
*/
@AfterMethod(alwaysRun = true)
public void finishTestMethod(Method method, ITestResult testResult) {
// stop video capture and log file
File videoFile = WebUIDriver.stopVideoCapture();
if (videoFile != null) {
VideoUtils.extractReferenceForSteps(videoFile, TestStepManager.getInstance().getTestSteps(), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
if (SeleniumTestsContextManager.getThreadContext().getVideoCapture() == VideoCaptureMode.TRUE || (SeleniumTestsContextManager.getThreadContext().getVideoCapture() == VideoCaptureMode.ON_SUCCESS && testResult.isSuccess()) || (SeleniumTestsContextManager.getThreadContext().getVideoCapture() == VideoCaptureMode.ON_ERROR && !testResult.isSuccess())) {
((ScenarioLogger) logger).logFileToTestEnd(videoFile.getAbsoluteFile(), "Video capture");
Info lastStateInfo = TestNGResultUtils.getTestInfo(testResult).get(TestStepManager.LAST_STATE_NAME);
if (lastStateInfo != null) {
((MultipleInfo) lastStateInfo).addInfo(new VideoLinkInfo(TestNGResultUtils.getUniqueTestName(testResult) + "/videoCapture.avi"));
}
logger.info("Video file copied to " + videoFile.getAbsolutePath());
} else {
try {
Files.delete(Paths.get(videoFile.getAbsolutePath()));
} catch (IOException e) {
logger.warn(String.format("Video file %s not deleted: %s", videoFile.getAbsoluteFile(), e.getMessage()));
}
}
}
WebUIDriver.cleanUp();
SeleniumTestsContextManager.getThreadContext().setDriverCreationBlocked(true);
SeleniumRobotTestListener.getCurrentListener().onTestFullyFinished(testResult);
}
use of com.seleniumtests.reporter.info.VideoLinkInfo in project seleniumRobot by bhecquet.
the class TestVideoLinkInfo method testHtmlLink.
@Test(groups = { "ut" })
public void testHtmlLink() {
String formatHtml = new VideoLinkInfo("/videoCapture.html").encode("html");
Assert.assertEquals(formatHtml, "<a href=\"/videoCapture.html\"><i class=\"fas fa-video\" aria-hidden=\"true\"></i></a>");
}
use of com.seleniumtests.reporter.info.VideoLinkInfo in project seleniumRobot by bhecquet.
the class TestVideoLinkInfo method testOtherFormatLink.
@Test(groups = { "ut" })
public void testOtherFormatLink() {
String formatOther = new VideoLinkInfo("/videoCapture.avi").encode("avi");
Assert.assertEquals(formatOther, "Video");
}
use of com.seleniumtests.reporter.info.VideoLinkInfo in project seleniumRobot by bhecquet.
the class TestVideoLinkInfo method testNullFormatLink.
@Test(groups = { "ut" })
public void testNullFormatLink() {
String formatNull = new VideoLinkInfo("/videoCapture.avi").encode(null);
Assert.assertEquals(formatNull, "Video");
}
Aggregations