Search in sources :

Example 11 with TestMessage

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

the class StubTestClass method testInError.

@Test(groups = "stub")
public void testInError() {
    TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    TestStepManager.setCurrentRootTestStep(step1);
    TestStepManager.getParentTestStep().addAction(new TestAction("click button", false, new ArrayList<>()));
    TestStepManager.getParentTestStep().addMessage(new TestMessage("click ok", MessageType.INFO));
    logger.warn("Some warning message");
    logger.info("Some Info message");
    logger.error("Some Error message");
    ((ScenarioLogger) logger).log("Some log message");
    ((ScenarioLogger) logger).logTestValue("key", "we found a value of", "10");
    TestStepManager.getParentTestStep().addAction(new TestAction("send keyboard action", false, new ArrayList<>()));
    TestStepManager.logTestStep(TestStepManager.getCurrentRootTestStep());
    Assert.fail("error");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) ScenarioLogger(com.seleniumtests.util.logging.ScenarioLogger) TestMessage(com.seleniumtests.reporter.logger.TestMessage) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test)

Example 12 with TestMessage

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

the class StubTestClass method testAndSubActions.

@Test(groups = "stub", description = "a test with steps")
public void testAndSubActions() throws IOException {
    TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    step1.addAction(new TestAction("click button", false, new ArrayList<>()));
    step1.addAction(new TestAction("sendKeys to text field", true, new ArrayList<>()));
    File tmpImg = File.createTempFile("img", "_with_very_very_very_long_name_to_be_shortened.png");
    File tmpHtml = File.createTempFile("html", "_with_very_very_very_long_name_to_be_shortened.html");
    ScreenShot screenshot = new ScreenShot();
    screenshot.setImagePath("screenshot/" + tmpImg.getName());
    screenshot.setHtmlSourcePath("htmls/" + tmpHtml.getName());
    FileUtils.copyFile(tmpImg, new File(screenshot.getFullImagePath()));
    FileUtils.copyFile(tmpHtml, new File(screenshot.getFullHtmlPath()));
    step1.addSnapshot(new Snapshot(screenshot, "main", SnapshotCheckType.FULL), 1, null);
    ScreenShot screenshot2 = new ScreenShot();
    screenshot2.setImagePath("screenshot/" + tmpImg.getName());
    screenshot2.setHtmlSourcePath("htmls/" + tmpHtml.getName());
    FileUtils.moveFile(tmpImg, new File(screenshot2.getFullImagePath()));
    FileUtils.moveFile(tmpHtml, new File(screenshot2.getFullHtmlPath()));
    step1.addSnapshot(new Snapshot(screenshot2, null, SnapshotCheckType.FULL), 1, null);
    step1.setActionException(new WebDriverException("driver exception"));
    TestStep subStep1 = new TestStep("step 1.3: open page", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    subStep1.addAction(new TestAction("click link", false, new ArrayList<>()));
    subStep1.addMessage(new TestMessage("a message", MessageType.LOG));
    subStep1.addAction(new TestAction("sendKeys to password field", false, new ArrayList<>()));
    step1.addAction(subStep1);
    WaitHelper.waitForSeconds(3);
    step1.setDuration(1230L);
    TestStep step2 = new TestStep("step 2", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    step2.setDuration(14030L);
    TestStepManager.logTestStep(step1);
    TestStepManager.logTestStep(step2);
    tmpImg.deleteOnExit();
    tmpHtml.deleteOnExit();
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Snapshot(com.seleniumtests.reporter.logger.Snapshot) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ArrayList(java.util.ArrayList) TestMessage(com.seleniumtests.reporter.logger.TestMessage) File(java.io.File) TestAction(com.seleniumtests.reporter.logger.TestAction) WebDriverException(org.openqa.selenium.WebDriverException) Test(org.testng.annotations.Test)

Example 13 with TestMessage

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

the class TestTestStep method testEncodeXml.

/**
 * Check Step / sub-step encoding with XML
 */
@Test(groups = { "ut" })
public void testEncodeXml() {
    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<>()));
    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);
    TestStep encodedTestStep = step.encode("xml");
    Assert.assertTrue(encodedTestStep.toString().contains("Step step1 &quot;&apos;&lt;&gt;&amp;"));
    Assert.assertTrue(encodedTestStep.toString().contains("everything OK &quot;&apos;&lt;&gt;&amp;"));
    Assert.assertTrue(encodedTestStep.toString().contains("action2 &quot;&apos;&lt;&gt;&amp;"));
    Assert.assertTrue(encodedTestStep.toString().contains("action1 &quot;&apos;&lt;&gt;&amp;"));
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ArrayList(java.util.ArrayList) TestMessage(com.seleniumtests.reporter.logger.TestMessage) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 14 with TestMessage

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

the class TestTestStep method testTestSubMessagePositionAndParent.

@Test(groups = { "ut" })
public void testTestSubMessagePositionAndParent() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    TestStep subStep = new TestStep("subStep1", null, new ArrayList<>(), true);
    step.addStep(subStep);
    TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
    step.addAction(message);
    Assert.assertEquals(message.getPosition(), 1);
    Assert.assertEquals(message.getParent(), step);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestMessage(com.seleniumtests.reporter.logger.TestMessage) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 15 with TestMessage

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

Aggregations

TestMessage (com.seleniumtests.reporter.logger.TestMessage)20 Test (org.testng.annotations.Test)17 TestStep (com.seleniumtests.reporter.logger.TestStep)16 GenericTest (com.seleniumtests.GenericTest)14 TestAction (com.seleniumtests.reporter.logger.TestAction)12 ArrayList (java.util.ArrayList)7 GenericFile (com.seleniumtests.reporter.logger.GenericFile)2 HarCapture (com.seleniumtests.reporter.logger.HarCapture)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 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)1 Snapshot (com.seleniumtests.reporter.logger.Snapshot)1 ScenarioLogger (com.seleniumtests.util.logging.ScenarioLogger)1 File (java.io.File)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 Document (org.jdom2.Document)1 Element (org.jdom2.Element)1 JDOMException (org.jdom2.JDOMException)1