use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestLogActions method testVideoStartDateSetWhenVideoRecordingEnabled.
@Test(groups = { "it" })
public void testVideoStartDateSetWhenVideoRecordingEnabled() throws Exception {
WebDriver driver = null;
try {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
driver = WebUIDriver.getWebDriver(true);
DriverTestPage testPage = new DriverTestPage(true);
WaitHelper.waitForSeconds(1);
testPage._writeSomething();
TestStepManager stepManager = SeleniumTestsContextManager.getThreadContext().getTestStepManager();
TestStep step = stepManager.getTestSteps().get(2);
Assert.assertTrue(step.getVideoTimeStamp() > 0);
Assert.assertNotNull(stepManager.getVideoStartDate());
} finally {
if (driver != null) {
WebUIDriver.cleanUp();
}
}
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestStep method testPasswordMaskingMainStep.
/**
* Check that if main step contains masking, they are reported in messages /
* action / step below
*/
@Test(groups = { "ut" })
public void testPasswordMaskingMainStep() {
TestStep step = new TestStep("step1 with args: (bar, passwd)", null, Arrays.asList("passwd"), true);
TestAction action = new TestAction("action in step1 with args: (foo, passwd)", false, new ArrayList<>());
TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
TestStep substep = new TestStep("substep with args: (passwd)", null, new ArrayList<>(), true);
step.addAction(action);
step.addMessage(message);
step.addStep(substep);
Assert.assertEquals(step.getName(), "step1 with args: (bar, ******)");
Assert.assertEquals(action.getName(), "action in step1 with args: (foo, ******)");
Assert.assertEquals(message.getName(), "everything OK on ******");
Assert.assertEquals(substep.getName(), "substep with args: (******)");
Assert.assertEquals(step.toString(), "Step step1 with args: (bar, ******)\n" + " - action in step1 with args: (foo, ******)\n" + " - everything OK on ******\n" + " - Step substep with args: (******)");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestStep method testTestStepEncodeXml.
@Test(groups = { "ut" })
public void testTestStepEncodeXml() {
TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>(), true, RootCause.REGRESSION, "\"'<>&", false);
// mandatory so that errorCauseDetails is not null
step.setFailed(true);
TestStep encodedTestStep = step.encode("xml");
Assert.assertEquals(encodedTestStep.toString(), "Step step1 "'<>&");
Assert.assertEquals(encodedTestStep.getRootCauseDetails(), ""'<>&");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestStep method testPasswordMaskingHtmlEncodedMainStep.
@Test(groups = { "ut" })
public void testPasswordMaskingHtmlEncodedMainStep() {
TestStep step = new TestStep("step1 with args: (bar, passwd)", null, Arrays.asList("passwd"), true);
TestAction action = new TestAction("action in step1 with args: (foo, passwd)", false, new ArrayList<>());
TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
TestStep substep = new TestStep("substep with args: (passwd)", null, new ArrayList<>(), true);
step.addAction(action);
step.addMessage(message);
step.addStep(substep);
Assert.assertEquals(step.encode("html").getName(), "step1 with args: (bar, ******)");
Assert.assertEquals(action.encode("html").getName(), "action in step1 with args: (foo, ******)");
Assert.assertEquals(message.encode("html").getName(), "everything OK on ******");
Assert.assertEquals(substep.encode("html").getName(), "substep with args: (******)");
Assert.assertEquals(step.encode("html").toString(), "Step step1 with args: (bar, ******)\n" + " - action in step1 with args: (foo, ******)\n" + " - everything OK on ******\n" + " - Step substep with args: (******)");
}
use of com.seleniumtests.reporter.logger.TestStep in project seleniumRobot by bhecquet.
the class TestTestStep method testMultipleSnapshotsInStep.
@Test(groups = { "ut" })
public void testMultipleSnapshotsInStep() throws IOException {
TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
ScreenShot screenshot = new ScreenShot();
File tmpImgFile = File.createTempFile("img", ".png");
File tmpImgFile2 = Paths.get(tmpImgFile.getParent(), "screenshots", tmpImgFile.getName()).toFile();
FileUtils.moveFile(tmpImgFile, tmpImgFile2);
File tmpHtmlFile = File.createTempFile("html", ".html");
File tmpHtmlFile2 = Paths.get(tmpHtmlFile.getParent(), "htmls", tmpHtmlFile.getName()).toFile();
FileUtils.moveFile(tmpHtmlFile, tmpHtmlFile2);
screenshot.setOutputDirectory(tmpImgFile.getParent());
screenshot.setLocation("http://mysite.com");
screenshot.setTitle("mysite");
screenshot.setImagePath("screenshots/" + tmpImgFile2.getName());
screenshot.setHtmlSourcePath("htmls/" + tmpHtmlFile2.getName());
step.addSnapshot(new Snapshot(screenshot, "main", SnapshotCheckType.TRUE), 0, null);
ScreenShot screenshotSubStep = new ScreenShot();
File tmpImgFileSubStep = File.createTempFile("img", ".png");
File tmpImgFileSubStep2 = Paths.get(tmpImgFileSubStep.getParent(), "screenshots", tmpImgFileSubStep.getName()).toFile();
FileUtils.moveFile(tmpImgFileSubStep, tmpImgFileSubStep2);
File tmpHtmlFileSubStep = File.createTempFile("html", ".html");
File tmpHtmlFileSubStep2 = Paths.get(tmpHtmlFileSubStep.getParent(), "htmls", tmpHtmlFileSubStep.getName()).toFile();
FileUtils.moveFile(tmpHtmlFileSubStep, tmpHtmlFileSubStep2);
screenshotSubStep.setOutputDirectory(tmpImgFileSubStep.getParent());
screenshotSubStep.setLocation("http://mysite.com");
screenshotSubStep.setTitle("mysite");
screenshotSubStep.setImagePath("screenshots/" + tmpImgFileSubStep2.getName());
screenshotSubStep.setHtmlSourcePath("htmls/" + tmpHtmlFileSubStep2.getName());
step.addSnapshot(new Snapshot(screenshotSubStep, "main", SnapshotCheckType.TRUE), 0, null);
Assert.assertEquals(step.getSnapshots().get(0).getScreenshot().getImagePath(), "screenshots/N-A_0-1_step1--" + tmpImgFile2.getName().substring(tmpImgFile2.getName().length() - 10));
Assert.assertEquals(step.getSnapshots().get(0).getScreenshot().getHtmlSourcePath(), "htmls/N-A_0-1_step1--" + tmpHtmlFile2.getName().substring(tmpHtmlFile2.getName().length() - 10));
Assert.assertEquals(step.getSnapshots().get(1).getScreenshot().getImagePath(), "screenshots/N-A_0-2_step1--" + tmpImgFileSubStep2.getName().substring(tmpImgFileSubStep2.getName().length() - 10));
Assert.assertEquals(step.getSnapshots().get(1).getScreenshot().getHtmlSourcePath(), "htmls/N-A_0-2_step1--" + tmpHtmlFileSubStep2.getName().substring(tmpHtmlFileSubStep2.getName().length() - 10));
tmpImgFile.deleteOnExit();
tmpHtmlFile.deleteOnExit();
tmpImgFileSubStep.deleteOnExit();
tmpHtmlFileSubStep.deleteOnExit();
}
Aggregations