Search in sources :

Example 41 with TestStep

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()));
}
Also used : LocalDateTime(java.time.LocalDateTime) TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 42 with TestStep

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");
}
Also used : LocalDateTime(java.time.LocalDateTime) TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 43 with TestStep

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);
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ITestResult(org.testng.ITestResult) ISuiteResult(org.testng.ISuiteResult) Test(org.testng.annotations.Test) ReporterTest(com.seleniumtests.it.reporter.ReporterTest)

Example 44 with TestStep

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);
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ITestResult(org.testng.ITestResult) ISuiteResult(org.testng.ISuiteResult) Test(org.testng.annotations.Test) ReporterTest(com.seleniumtests.it.reporter.ReporterTest)

Example 45 with TestStep

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();
        }
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) TestStep(com.seleniumtests.reporter.logger.TestStep) DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) TestStepManager(com.seleniumtests.core.TestStepManager) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

TestStep (com.seleniumtests.reporter.logger.TestStep)190 Test (org.testng.annotations.Test)148 GenericTest (com.seleniumtests.GenericTest)120 ArrayList (java.util.ArrayList)80 TestAction (com.seleniumtests.reporter.logger.TestAction)47 File (java.io.File)37 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)25 Snapshot (com.seleniumtests.reporter.logger.Snapshot)24 ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)19 TestMessage (com.seleniumtests.reporter.logger.TestMessage)16 GenericFile (com.seleniumtests.reporter.logger.GenericFile)15 MockitoTest (com.seleniumtests.MockitoTest)12 HashMap (java.util.HashMap)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 ITestResult (org.testng.ITestResult)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 Uft (com.seleniumtests.connectors.extools.Uft)8 DriverExceptions (com.seleniumtests.customexception.DriverExceptions)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)7 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)6