use of net.lightbody.bmp.core.har.HarLog in project seleniumRobot by bhecquet.
the class TestTestLogging method testRelocateHarNull.
/**
* Test no error is raised is outputDirectory is null
* @throws IOException
*/
@Test(groups = { "ut" })
public void testRelocateHarNull() 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(null);
} finally {
FileUtils.deleteQuietly(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
}
}
use of net.lightbody.bmp.core.har.HarLog 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>");
}
use of net.lightbody.bmp.core.har.HarLog 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"));
}
}
use of net.lightbody.bmp.core.har.HarLog 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());
}
use of net.lightbody.bmp.core.har.HarLog in project seleniumRobot by bhecquet.
the class TestTestStep method testTestStepEncodeXmlHarKept.
@Test(groups = { "ut" })
public void testTestStepEncodeXmlHarKept() throws IOException {
Har har = new Har(new HarLog());
har.getLog().addPage(new HarPage("title", "a title"));
HarCapture cap = new HarCapture(har, "main");
TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>(), true);
step.setHarCaptures(Arrays.asList(cap));
TestStep encodedTestStep = step.encode("xml");
Assert.assertEquals(encodedTestStep.getHarCaptures().get(0), cap);
}
Aggregations