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");
}
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();
}
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 "'<>&"));
Assert.assertTrue(encodedTestStep.toString().contains("everything OK "'<>&"));
Assert.assertTrue(encodedTestStep.toString().contains("action2 "'<>&"));
Assert.assertTrue(encodedTestStep.toString().contains("action1 "'<>&"));
}
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);
}
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");
}
Aggregations