use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestVideoUtils method testReadAviInvalidFile.
/**
* Test invalid file, no exception should be raised
* @throws IOException
*/
@Test(groups = { "ut" })
public void testReadAviInvalidFile() throws IOException {
LocalDateTime videoStartDateTime = LocalDateTime.parse("2021-11-15T13:15:30");
TestStepManager.getInstance().setVideoStartDate(Date.from(videoStartDateTime.toInstant(ZoneOffset.UTC)));
TestStep step = new TestStep("step 1", null, new ArrayList<String>(), false);
step.setStartDate(Date.from(videoStartDateTime.plusSeconds(1).toInstant(ZoneOffset.UTC)));
step.setVideoTimeStamp(1000);
Assert.assertEquals(step.getSnapshots().size(), 0);
VideoUtils.extractReferenceForSteps(createVideoFileFromResource("tu/env.ini"), Arrays.asList(step), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestVideoUtils method testReadAvi.
/**
* Check a picture is extracted for each test step
* @throws IOException
*/
@Test(groups = { "ut" })
public void testReadAvi() throws IOException {
LocalDateTime videoStartDateTime = LocalDateTime.parse("2021-11-15T13:15:30");
TestStepManager.getInstance().setVideoStartDate(Date.from(videoStartDateTime.toInstant(ZoneOffset.UTC)));
TestStep step = new TestStep("step 1", null, new ArrayList<String>(), false);
step.setStartDate(Date.from(videoStartDateTime.plusSeconds(1).toInstant(ZoneOffset.UTC)));
step.setVideoTimeStamp(1000);
Assert.assertEquals(step.getSnapshots().size(), 0);
VideoUtils.extractReferenceForSteps(createVideoFileFromResource("tu/video/videoCapture.avi"), Arrays.asList(step), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
Assert.assertEquals(step.getSnapshots().size(), 1);
Assert.assertEquals(step.getSnapshots().get(0).getName(), "Step beginning state");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestScreenshotUtil method testNoScrollDelay.
/**
* Test scrollDelay=0
* Check capture delay is not too high
* @throws Exception
*/
@Test(groups = { "it" })
public void testNoScrollDelay() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SNAPSHOT_SCROLL_DELAY, "0");
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForDriverTest" }, ParallelMode.METHODS, new String[] { "testDriverCustomSnapshot" });
for (ISuiteResult suiteResult : SeleniumRobotTestListener.getSuiteList().get(0).getResults().values()) {
for (ITestResult testResult : suiteResult.getTestContext().getPassedTests().getAllResults()) {
List<TestStep> steps = TestNGResultUtils.getSeleniumRobotTestContext(testResult).getTestStepManager().getTestSteps();
for (TestStep step : steps) {
if ("_captureSnapshot with args: (my snapshot, )".equals(step.getName())) {
Assert.assertTrue(step.getSnapshots().get(0).getDurationToExclude() < 3000);
return;
}
}
}
}
Assert.fail("step has not been found");
} finally {
System.clearProperty(SeleniumTestsContext.SNAPSHOT_SCROLL_DELAY);
}
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestScreenshotUtil method testWithScrollDelay.
/**
* Test scrollDelay=1000 so that it can be distinguished
* Check that capture for report (when page opens or for 'Test end') is not affected by the scrollDelay setting
* Check that for image comparison, setting is used
* @throws Exception
*/
@Test(groups = { "it" })
public void testWithScrollDelay() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SNAPSHOT_SCROLL_DELAY, "1000");
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForDriverTest" }, ParallelMode.METHODS, new String[] { "testDriverCustomSnapshot" });
int checkNumbers = 0;
for (ISuiteResult suiteResult : SeleniumRobotTestListener.getSuiteList().get(0).getResults().values()) {
for (ITestResult testResult : suiteResult.getTestContext().getPassedTests().getAllResults()) {
List<TestStep> steps = TestNGResultUtils.getSeleniumRobotTestContext(testResult).getTestStepManager().getTestSteps();
for (TestStep step : steps) {
// check that standard screenshots are not affected by scrollDelay setting
if (step.getName().startsWith("openPage with args: ")) {
Assert.assertTrue(step.getSnapshots().get(0).getDurationToExclude() < 3000);
checkNumbers++;
} else // check that screenshots used for image comparison are affected by scrollDelay setting
if ("_captureSnapshot with args: (my snapshot, )".equals(step.getName())) {
Assert.assertTrue(step.getSnapshots().get(0).getDurationToExclude() > 4000);
Assert.assertEquals(checkNumbers, 1);
return;
}
}
}
}
Assert.fail("step has not been found");
} finally {
System.clearProperty(SeleniumTestsContext.SNAPSHOT_SCROLL_DELAY);
}
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestLogActions method testVideoStartDateSetWhenVideoRecordingDisabled.
@Test(groups = { "it" })
public void testVideoStartDateSetWhenVideoRecordingDisabled() throws Exception {
WebDriver driver = null;
try {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
SeleniumTestsContextManager.getThreadContext().setVideoCapture("false");
driver = WebUIDriver.getWebDriver(true);
DriverTestPage testPage = new DriverTestPage(true);
WaitHelper.waitForSeconds(1);
testPage._writeSomething();
TestStepManager stepManager = SeleniumTestsContextManager.getThreadContext().getTestStepManager();
TestStep step = stepManager.getTestSteps().get(2);
Assert.assertEquals(step.getVideoTimeStamp(), 0);
Assert.assertNull(stepManager.getVideoStartDate());
} finally {
if (driver != null) {
WebUIDriver.cleanUp();
}
}
}
Aggregations