Search in sources :

Example 1 with HarCapture

use of com.seleniumtests.reporter.logger.HarCapture 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 2 with HarCapture

use of com.seleniumtests.reporter.logger.HarCapture 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);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) HarLog(net.lightbody.bmp.core.har.HarLog) 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 3 with HarCapture

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

the class TestTestStep method testTestSubCapturePositionAndParent.

@Test(groups = { "ut" })
public void testTestSubCapturePositionAndParent() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    TestStep subStep = new TestStep("subStep1", null, new ArrayList<>(), true);
    step.addStep(subStep);
    Har har = new Har(new HarLog());
    har.getLog().addPage(new HarPage("title", "a title"));
    HarCapture capture = new HarCapture(har, "main");
    step.addNetworkCapture(capture);
    Assert.assertEquals(capture.getPosition(), 1);
    Assert.assertEquals(capture.getParent(), step);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) HarLog(net.lightbody.bmp.core.har.HarLog) 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 4 with HarCapture

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

the class TestTestStep method testToString.

@Test(groups = { "ut" })
public void testToString() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.addMessage(new TestMessage("everything OK", MessageType.INFO));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    Har har = new Har(new HarLog());
    har.getLog().addPage(new HarPage("title", "a title"));
    step.addNetworkCapture(new HarCapture(har, "main"));
    GenericFile file = new GenericFile(File.createTempFile("video", ".avi"), "video file");
    step.addFile(file);
    TestStep subStep = new TestStep("subStep", null, new ArrayList<>(), true);
    subStep.addMessage(new TestMessage("everything in subStep almost OK", MessageType.WARNING));
    subStep.addAction(new TestAction("action1", false, new ArrayList<>()));
    step.addAction(subStep);
    step.addAction(new TestAction("action3", false, new ArrayList<>()));
    Assert.assertEquals(step.toString(), "Step step1\n" + "  - everything OK\n" + "  - action2\n" + "  - Step subStep\n" + "    - everything in subStep almost OK\n" + "    - action1\n" + "  - action3");
}
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) TestMessage(com.seleniumtests.reporter.logger.TestMessage) HarPage(net.lightbody.bmp.core.har.HarPage) GenericFile(com.seleniumtests.reporter.logger.GenericFile) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 5 with HarCapture

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

the class TestTestStep method testToJson.

/**
 * Checks getFailed correctly compute test step status if sub step is not failed
 *
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testToJson() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.addMessage(new TestMessage("everything OK", MessageType.INFO));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    Har har = new Har(new HarLog());
    har.getLog().addPage(new HarPage("title", "a title"));
    step.addNetworkCapture(new HarCapture(har, "main"));
    GenericFile file = new GenericFile(File.createTempFile("video", ".avi"), "video file");
    step.addFile(file);
    TestStep subStep = new TestStep("subStep", null, new ArrayList<>(), true);
    subStep.addMessage(new TestMessage("everything in subStep almost OK", MessageType.WARNING));
    subStep.addAction(new TestAction("action1", false, new ArrayList<>()));
    step.addAction(subStep);
    JSONObject stepJson = step.toJson();
    Assert.assertEquals(stepJson.getString("type"), "step");
    Assert.assertEquals(stepJson.getString("name"), "step1");
    Assert.assertEquals(stepJson.getJSONArray("actions").length(), 3);
    // check actions order
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(0).getString("type"), "message");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(0).getString("messageType"), "INFO");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(1).getString("type"), "action");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(1).getString("name"), "action2");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(1).getBoolean("failed"), false);
    Assert.assertEquals(stepJson.getJSONArray("harCaptures").getJSONObject(0).getString("type"), "networkCapture");
    Assert.assertEquals(stepJson.getJSONArray("harCaptures").getJSONObject(0).getString("name"), "main");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(2).getString("type"), "step");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(2).getString("name"), "subStep");
    Assert.assertEquals(stepJson.getJSONArray("actions").getJSONObject(2).getJSONArray("actions").length(), 2);
    Assert.assertEquals(stepJson.getJSONArray("files").getJSONObject(0).getString("type"), "file");
    Assert.assertEquals(stepJson.getJSONArray("files").getJSONObject(0).getString("name"), "video file");
    Assert.assertTrue(stepJson.getJSONArray("files").getJSONObject(0).getString("file").contains(".avi"));
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) HarLog(net.lightbody.bmp.core.har.HarLog) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) Har(net.lightbody.bmp.core.har.Har) HarCapture(com.seleniumtests.reporter.logger.HarCapture) TestMessage(com.seleniumtests.reporter.logger.TestMessage) HarPage(net.lightbody.bmp.core.har.HarPage) GenericFile(com.seleniumtests.reporter.logger.GenericFile) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

GenericTest (com.seleniumtests.GenericTest)5 HarCapture (com.seleniumtests.reporter.logger.HarCapture)5 TestStep (com.seleniumtests.reporter.logger.TestStep)5 Har (net.lightbody.bmp.core.har.Har)5 HarLog (net.lightbody.bmp.core.har.HarLog)5 HarPage (net.lightbody.bmp.core.har.HarPage)5 Test (org.testng.annotations.Test)5 ArrayList (java.util.ArrayList)3 GenericFile (com.seleniumtests.reporter.logger.GenericFile)2 TestAction (com.seleniumtests.reporter.logger.TestAction)2 TestMessage (com.seleniumtests.reporter.logger.TestMessage)2 JSONObject (org.json.JSONObject)1