Search in sources :

Example 51 with TestAction

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

the class TestTestStep method testGetFailedWithActionKo.

/**
 * Checks getStepStatus correctly compute test step status if action is failed
 * Step is OK
 */
@Test(groups = { "ut" })
public void testGetFailedWithActionKo() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.addAction(new TestAction("action1", false, new ArrayList<>()));
    step.addAction(new TestAction("action2", true, new ArrayList<>()));
    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 52 with TestAction

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

the class TestTestStep method testListAllAttachments.

/**
 * Check we get all files from a step and its sub steps
 *
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testListAllAttachments() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    // create screenshot for main step
    ScreenShot screenshot1 = 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);
    tmpImgFile.deleteOnExit();
    tmpHtmlFile.deleteOnExit();
    screenshot1.setOutputDirectory(tmpImgFile.getParent());
    screenshot1.setLocation("http://mysite.com");
    screenshot1.setTitle("mysite");
    screenshot1.setImagePath("screenshots/" + tmpImgFile2.getName());
    screenshot1.setHtmlSourcePath("htmls/" + tmpHtmlFile2.getName());
    step.addSnapshot(new Snapshot(screenshot1, "main", SnapshotCheckType.FALSE), 0, null);
    TestStep subStep = new TestStep("subStep", null, new ArrayList<>(), true);
    // create screenshot for sub step
    ScreenShot screenshot2 = new ScreenShot();
    File tmpImgFile3 = File.createTempFile("img", ".png");
    File tmpImgFile4 = Paths.get(tmpImgFile3.getParent(), "screenshots", tmpImgFile3.getName()).toFile();
    FileUtils.moveFile(tmpImgFile3, tmpImgFile4);
    screenshot2.setOutputDirectory(tmpImgFile3.getParent());
    screenshot2.setLocation("http://mysite.com");
    screenshot2.setTitle("mysite");
    screenshot2.setImagePath("screenshots/" + tmpImgFile4.getName());
    subStep.addSnapshot(new Snapshot(screenshot2, "main", SnapshotCheckType.TRUE), 0, null);
    subStep.addAction(new TestAction("action1", true, new ArrayList<>()));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    step.addAction(subStep);
    List<File> attachments = step.getAllAttachments();
    Assert.assertEquals(attachments.size(), 3);
    Assert.assertEquals(attachments.get(0).getName(), "N-A_0-1_step1--" + tmpHtmlFile2.getName().substring(tmpHtmlFile2.getName().length() - 10));
    Assert.assertEquals(attachments.get(1).getName(), "N-A_0-1_step1--" + tmpImgFile2.getName().substring(tmpImgFile2.getName().length() - 10));
    Assert.assertEquals(attachments.get(2).getName(), "N-A_0-1_subStep--" + tmpImgFile4.getName().substring(tmpImgFile4.getName().length() - 10));
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Snapshot(com.seleniumtests.reporter.logger.Snapshot) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ArrayList(java.util.ArrayList) File(java.io.File) GenericFile(com.seleniumtests.reporter.logger.GenericFile) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 53 with TestAction

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

the class TestTestStep method testPasswordMaskingHtmlEncodedMainStepWithSpecialCharacters.

/**
 * issue #431: check encoded steps have there password encoded when using special characters
 */
@Test(groups = { "ut" })
public void testPasswordMaskingHtmlEncodedMainStepWithSpecialCharacters() {
    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: (******)");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestMessage(com.seleniumtests.reporter.logger.TestMessage) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 54 with TestAction

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

the class TestTestStep method testNoPasswordMasking.

/**
 * check that when disabled, password masking does not change test step
 */
@Test(groups = { "ut" })
public void testNoPasswordMasking() {
    TestStep step = new TestStep("step1 with args: (bar, passwd)", null, new ArrayList<>(), false);
    TestStep substep = new TestStep("substep with args: (passwd)", null, Arrays.asList("passwd"), false);
    TestAction action = new TestAction("action in step1 with args: (foo, passwd)", false, new ArrayList<>());
    TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
    step.addAction(substep);
    substep.addAction(action);
    substep.addMessage(message);
    Assert.assertEquals(step.getName(), "step1 with args: (bar, passwd)");
    Assert.assertEquals(action.getName(), "action in step1 with args: (foo, passwd)");
    Assert.assertEquals(message.getName(), "everything OK on passwd");
    Assert.assertEquals(substep.getName(), "substep with args: (passwd)");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestMessage(com.seleniumtests.reporter.logger.TestMessage) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 55 with TestAction

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

the class TestTestStep method testGetFailedWithStepKo.

/**
 * Checks getStepStatus correctly compute test step status if action is not
 * failed but test step is KO
 */
@Test(groups = { "ut" })
public void testGetFailedWithStepKo() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.setFailed(true);
    step.addAction(new TestAction("action1", false, new ArrayList<>()));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    Assert.assertTrue(step.getFailed());
    Assert.assertEquals(step.getStepStatus(), StepStatus.FAILED);
}
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)

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