use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class TestLogActions method testSubStepsNonCucumberStepLogging.
/**
* Check presence of sub steps. These are methods defined in Page object but not directly called from main test. We should get
* - page opening
* - add(1, 1)
* - nothing
* - doNothing on HtmlElement none
* - add(2) => step
* - add (2, 2) => sub-step
* - donothing => sub-step
* - doNothing on HtmlElement none => action on element
* Checks that root steps are correctly intercepted
* @throws IOException
*/
@Test(groups = { "it" })
public void testSubStepsNonCucumberStepLogging() throws IOException {
new CalcPage().add(1, 1).add(2);
List<TestStep> steps = SeleniumTestsContextManager.getThreadContext().getTestStepManager().getTestSteps();
Assert.assertEquals(steps.size(), 3);
Assert.assertEquals(steps.get(0).getName(), "openPage with args: (null, )");
Assert.assertEquals(steps.get(1).getName(), "add with args: (1, 1, )");
Assert.assertEquals(steps.get(2).getName(), "add with args: (2, )");
Assert.assertEquals(steps.get(1).getStepActions().size(), 1);
TestStep subStep = (TestStep) steps.get(1).getStepActions().get(0);
Assert.assertEquals(subStep.getStepActions().size(), 1);
Assert.assertEquals(subStep.getName(), "doNothing ");
TestAction subSubAction = subStep.getStepActions().get(0);
Assert.assertEquals(subSubAction.getName(), "doNothing on HtmlElement none, by={By.id: none} ");
Assert.assertEquals(steps.get(2).getStepActions().size(), 1);
subStep = (TestStep) steps.get(2).getStepActions().get(0);
Assert.assertEquals(subStep.getStepActions().size(), 1);
Assert.assertEquals(subStep.getName(), "add with args: (2, 2, )");
TestStep subSubStep = (TestStep) subStep.getStepActions().get(0);
Assert.assertEquals(subSubStep.getName(), "doNothing ");
}
use of com.seleniumtests.reporter.logger.TestAction 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.TestAction in project seleniumRobot by bhecquet.
the class StubTestClass method testWithException2.
/**
* An other test that throws exception
*/
@Test(groups = "stub", dependsOnMethods = "testAndSubActions")
public void testWithException2() {
TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
step1.addAction(new TestAction(String.format("played %d times", count), false, new ArrayList<>()));
step1.addAction(new TestAction("click button", false, new ArrayList<>()));
TestStepManager.logTestStep(step1);
throw new DriverExceptions("some exception");
}
use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.
the class StubTestClass method testWithSocketTimeoutOnFirstExec.
/**
* Test which fails only on first execution
*/
@Test(groups = "stub")
public void testWithSocketTimeoutOnFirstExec() {
TestStep step1 = new TestStep("step 10", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
step1.addAction(new TestAction(String.format("played %d times", count), false, new ArrayList<>()));
step1.addAction(new TestAction("click button", false, new ArrayList<>()));
TestStepManager.logTestStep(step1);
if (!failed) {
failed = true;
throw new WebDriverException("Session [6919ba25-53b6-4615-bd59-e97399bf1e12] was terminated due to SO_TIMEOUT");
}
}
use of com.seleniumtests.reporter.logger.TestAction 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();
}
Aggregations