Search in sources :

Example 16 with TestStep

use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.

the class TestTestLogging method testLogFileSamePlace.

/**
 * Check no error is raised if file is already at the right place
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testLogFileSamePlace() throws IOException {
    TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
    File videoFile = File.createTempFile("video", ".avi");
    FileUtils.moveFile(videoFile, Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile());
    logger.logFile(videoFile, "video");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 17 with TestStep

use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.

the class TestTestLogging method testRelocateScreenshotImageOnly.

/**
 * Check image file is moved
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testRelocateScreenshotImageOnly() throws IOException {
    try {
        TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
        ScreenShot screenshot = new ScreenShot();
        String imgSourcePath = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), ScreenshotUtil.SCREENSHOT_DIR, "capture.png").toString();
        FileUtils.write(new File(imgSourcePath), "<img>");
        // copied from ScreeshotUtils class
        screenshot.setImagePath(String.format("%s/%s.png", ScreenshotUtil.SCREENSHOT_DIR, "capture"));
        logger.logScreenshot(screenshot);
        File initialFile = new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullImagePath());
        // file exists before moving
        Assert.assertTrue(initialFile.exists());
        Assert.assertEquals(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getHtmlSource(), "");
        // relocate
        TestStepManager.getParentTestStep().getSnapshots().get(0).relocate(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved");
        File movedFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved", ScreenshotUtil.SCREENSHOT_DIR, "N-A_0-1_step--apture.png").toFile();
        Assert.assertTrue(movedFile.exists());
        Assert.assertFalse(initialFile.exists());
        Assert.assertEquals(new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullImagePath()), movedFile);
    } finally {
        FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
        FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved"));
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 18 with TestStep

use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.

the class TestTestLogging method testBuildHarLog.

@Test(groups = { "ut" })
public void testBuildHarLog() throws IOException {
    TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
    Har har = new Har(new HarLog());
    har.getLog().addPage(new HarPage("title", "a title"));
    HarCapture capture = new HarCapture(har, "main");
    Assert.assertEquals(capture.buildHarLog(), "Network capture 'main' browser: <a href='main-networkCapture.har'>HAR file</a>");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) HarLog(net.lightbody.bmp.core.har.HarLog) ArrayList(java.util.ArrayList) Har(net.lightbody.bmp.core.har.Har) HarCapture(com.seleniumtests.reporter.logger.HarCapture) HarPage(net.lightbody.bmp.core.har.HarPage) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 19 with TestStep

use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.

the class TestTestLogging method testLogFile.

// GenericFile
@Test(groups = { "ut" })
public void testLogFile() throws IOException {
    TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
    File videoFile = File.createTempFile("video", ".avi");
    videoFile.deleteOnExit();
    logger.logFile(videoFile, "video");
    // check file has been moved to log folder
    Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile().exists());
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 20 with TestStep

use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.

the class TestTestLogging method testLog.

@Test(groups = { "ut" })
public void testLog() {
    TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
    logger.log("message");
    Assert.assertEquals(((TestMessage) (TestStepManager.getParentTestStep().getStepActions().get(0))).getMessageType(), MessageType.LOG);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) 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