Search in sources :

Example 21 with TestStep

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

the class TestTestLogging method testWarning.

@Test(groups = { "ut" })
public void testWarning() {
    TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
    logger.warning("message");
    Assert.assertEquals(((TestMessage) (TestStepManager.getParentTestStep().getStepActions().get(0))).getMessageType(), MessageType.WARNING);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 22 with TestStep

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

the class TestTestLogging method testRelocateHar.

@Test(groups = { "ut" })
public void testRelocateHar() throws IOException {
    try {
        TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
        Har har = new Har(new HarLog());
        har.getLog().addPage(new HarPage("title", "a title"));
        logger.logNetworkCapture(har, "main");
        File initialFile = TestStepManager.getParentTestStep().getHarCaptures().get(0).getFile();
        // file exists before moving
        Assert.assertTrue(initialFile.exists());
        // relocate
        TestStepManager.getParentTestStep().getHarCaptures().get(0).relocate(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved");
        File movedFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved", "main-networkCapture.har").toFile();
        Assert.assertTrue(movedFile.exists());
        Assert.assertFalse(initialFile.exists());
        Assert.assertEquals(TestStepManager.getParentTestStep().getHarCaptures().get(0).getFile(), 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) HarLog(net.lightbody.bmp.core.har.HarLog) ArrayList(java.util.ArrayList) Har(net.lightbody.bmp.core.har.Har) HarPage(net.lightbody.bmp.core.har.HarPage) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 23 with TestStep

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

the class TestTestLogging method testRelocateScreenshotHtmlOnly.

/**
 * Check HTML page is moved
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testRelocateScreenshotHtmlOnly() throws IOException {
    try {
        TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
        ScreenShot screenshot = new ScreenShot();
        String htmlSourcePath = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), ScreenshotUtil.HTML_DIR, "capture.html").toString();
        FileUtils.write(new File(htmlSourcePath), "<html>");
        // copied from ScreeshotUtils class
        screenshot.setHtmlSourcePath(String.format("../%s/%s/%s.html", "testRelocateScreenshotHtmlOnly", ScreenshotUtil.HTML_DIR, "capture"));
        logger.logScreenshot(screenshot);
        File initialFile = new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullHtmlPath());
        // file exists before moving
        Assert.assertTrue(initialFile.exists());
        Assert.assertNull(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getImagePath());
        // relocate
        TestStepManager.getParentTestStep().getSnapshots().get(0).relocate(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved");
        File movedFile = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "_moved", ScreenshotUtil.HTML_DIR, "N-A_0-1_step--pture.html").toFile();
        Assert.assertTrue(movedFile.exists());
        Assert.assertFalse(initialFile.exists());
        Assert.assertEquals(new File(TestStepManager.getParentTestStep().getSnapshots().get(0).getScreenshot().getFullHtmlPath()), 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 24 with TestStep

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

the class TestTestLogging method testLogHarOk.

@Test(groups = { "ut" })
public void testLogHarOk() {
    TestStepManager.setCurrentRootTestStep(new TestStep("step", null, new ArrayList<>(), true));
    Har har = new Har(new HarLog());
    har.getLog().addPage(new HarPage("title", "a title"));
    logger.logNetworkCapture(har, "main");
    Assert.assertFalse(TestStepManager.getParentTestStep().getHarCaptures().isEmpty());
    Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), "main-networkCapture.har").toFile().exists());
}
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) HarPage(net.lightbody.bmp.core.har.HarPage) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 25 with TestStep

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

the class TestTestStep method testPasswordMaskingSubStep.

/**
 * Check that if a substep adds password values, parent step is not impacted
 */
@Test(groups = { "ut" })
public void testPasswordMaskingSubStep() {
    TestStep step = new TestStep("step1 with args: (bar, passwd)", null, new ArrayList<>(), true);
    TestStep substep = new TestStep("substep with args: (passwd)", null, Arrays.asList("passwd"), true);
    TestAction action = new TestAction("action in step1 with args: (foo, passwd)", false, new ArrayList<>());
    TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
    step.addAction(substep);
    substep.addAction(action);
    substep.addMessage(message);
    Assert.assertEquals(step.getName(), "step1 with args: (bar, passwd)");
    Assert.assertEquals(action.getName(), "action in step1 with args: (foo, ******)");
    Assert.assertEquals(message.getName(), "everything OK on ******");
    Assert.assertEquals(substep.getName(), "substep with args: (******)");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestMessage(com.seleniumtests.reporter.logger.TestMessage) TestAction(com.seleniumtests.reporter.logger.TestAction) 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