use of com.seleniumtests.util.logging.ScenarioLogger 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.util.logging.ScenarioLogger in project seleniumRobot by bhecquet.
the class StubTestClassForListener5 method startDriver.
private void startDriver() {
WebDriver driver = WebUIDriver.getWebDriver(true);
driver.get("file:///" + Thread.currentThread().getContextClassLoader().getResource("tu/test.html").getFile());
((ScenarioLogger) logger).logScreenshot(new ScreenshotUtil(driver).capture(SnapshotTarget.PAGE, ScreenShot.class));
}
use of com.seleniumtests.util.logging.ScenarioLogger in project seleniumRobot by bhecquet.
the class StubTestClass method testInError.
@Test(groups = "stub")
public void testInError() {
TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
TestStepManager.setCurrentRootTestStep(step1);
TestStepManager.getParentTestStep().addAction(new TestAction("click button", false, new ArrayList<>()));
TestStepManager.getParentTestStep().addMessage(new TestMessage("click ok", MessageType.INFO));
logger.warn("Some warning message");
logger.info("Some Info message");
logger.error("Some Error message");
((ScenarioLogger) logger).log("Some log message");
((ScenarioLogger) logger).logTestValue("key", "we found a value of", "10");
TestStepManager.getParentTestStep().addAction(new TestAction("send keyboard action", false, new ArrayList<>()));
TestStepManager.logTestStep(TestStepManager.getCurrentRootTestStep());
Assert.fail("error");
}
Aggregations