Search in sources :

Example 1 with VideoLinkInfo

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);
}
Also used : ScenarioLogger(com.seleniumtests.util.logging.ScenarioLogger) MultipleInfo(com.seleniumtests.reporter.info.MultipleInfo) IOException(java.io.IOException) Info(com.seleniumtests.reporter.info.Info) MultipleInfo(com.seleniumtests.reporter.info.MultipleInfo) VideoLinkInfo(com.seleniumtests.reporter.info.VideoLinkInfo) VideoLinkInfo(com.seleniumtests.reporter.info.VideoLinkInfo) File(java.io.File) AfterMethod(org.testng.annotations.AfterMethod)

Example 2 with VideoLinkInfo

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>");
}
Also used : VideoLinkInfo(com.seleniumtests.reporter.info.VideoLinkInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 3 with VideoLinkInfo

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");
}
Also used : VideoLinkInfo(com.seleniumtests.reporter.info.VideoLinkInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 4 with VideoLinkInfo

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");
}
Also used : VideoLinkInfo(com.seleniumtests.reporter.info.VideoLinkInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

VideoLinkInfo (com.seleniumtests.reporter.info.VideoLinkInfo)4 GenericTest (com.seleniumtests.GenericTest)3 Test (org.testng.annotations.Test)3 Info (com.seleniumtests.reporter.info.Info)1 MultipleInfo (com.seleniumtests.reporter.info.MultipleInfo)1 ScenarioLogger (com.seleniumtests.util.logging.ScenarioLogger)1 File (java.io.File)1 IOException (java.io.IOException)1 AfterMethod (org.testng.annotations.AfterMethod)1