Search in sources :

Example 46 with TestAction

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

the class TestTestStep method testDuration.

/**
 * Check duration is correctly handled in simple step with action exclusions
 */
@Test(groups = { "ut" })
public void testDuration() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.setDuration(5000L);
    step.setDurationToExclude(500L);
    TestAction action = new TestAction("action2", false, new ArrayList<>());
    action.setDurationToExclude(600L);
    step.addAction(action);
    Assert.assertEquals(step.getDuration(), (Long) 3900L);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 47 with TestAction

use of com.seleniumtests.reporter.logger.TestAction 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)

Example 48 with TestAction

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

the class TestTestStep method testGetFailedWithActionOk.

/**
 * Checks getStepStatus correctly compute test step status if action is not
 * failed
 */
@Test(groups = { "ut" })
public void testGetFailedWithActionOk() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.addAction(new TestAction("action1", false, new ArrayList<>()));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    Assert.assertFalse(step.getFailed());
    Assert.assertEquals(step.getStepStatus(), StepStatus.SUCCESS);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 49 with TestAction

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

the class TestTestStep method testGetFailedWithActionSubStepKo.

/**
 * Checks getStepStatus correctly compute test step status if sub step is failed
 */
@Test(groups = { "ut" })
public void testGetFailedWithActionSubStepKo() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    TestStep subStep = new TestStep("subStep", null, new ArrayList<>(), true);
    subStep.addAction(new TestAction("action1", true, new ArrayList<>()));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    step.addAction(subStep);
    Assert.assertFalse(step.getFailed());
    Assert.assertEquals(step.getStepStatus(), StepStatus.WARNING);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 50 with TestAction

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

the class TestTestStep method testTestActionEncodeXmlFailedStatus.

@Test(groups = { "ut" })
public void testTestActionEncodeXmlFailedStatus() {
    TestAction action = new TestAction("action2 \"'<>&", true, new ArrayList<>());
    TestAction encodedAction = action.encode("xml");
    Assert.assertTrue(encodedAction.getFailed());
}
Also used : TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

TestAction (com.seleniumtests.reporter.logger.TestAction)56 TestStep (com.seleniumtests.reporter.logger.TestStep)47 Test (org.testng.annotations.Test)44 ArrayList (java.util.ArrayList)38 GenericTest (com.seleniumtests.GenericTest)24 TestMessage (com.seleniumtests.reporter.logger.TestMessage)12 DriverExceptions (com.seleniumtests.customexception.DriverExceptions)8 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)5 Snapshot (com.seleniumtests.reporter.logger.Snapshot)5 File (java.io.File)5 HashMap (java.util.HashMap)5 GenericFile (com.seleniumtests.reporter.logger.GenericFile)3 Element (org.jdom2.Element)3 WebDriverException (org.openqa.selenium.WebDriverException)3 HarCapture (com.seleniumtests.reporter.logger.HarCapture)2 PageObject (com.seleniumtests.uipage.PageObject)2 Instant (java.time.Instant)2 Har (net.lightbody.bmp.core.har.Har)2 HarLog (net.lightbody.bmp.core.har.HarLog)2 HarPage (net.lightbody.bmp.core.har.HarPage)2