Search in sources :

Example 51 with TestStep

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

the class TestTestStep method testTestStepEncodeXmlWebDriverExceptionKept.

/**
 * Check that in case of a webdriver exception, platform information and capabilities are not returned
 */
@Test(groups = { "ut" })
public void testTestStepEncodeXmlWebDriverExceptionKept() {
    TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>(), true);
    step.setActionException(new NoSuchElementException("foo"));
    TestStep encodedTestStep = step.encode("xml");
    Assert.assertNotNull(encodedTestStep.getActionException());
    Assert.assertEquals(encodedTestStep.getActionExceptionMessage(), "class org.openqa.selenium.NoSuchElementException: foo\n");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) NoSuchElementException(org.openqa.selenium.NoSuchElementException) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 52 with TestStep

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

the class TestTestStep method testTestStepEncodeXmlStatusFailed.

/**
 * check failed status is kept
 */
@Test(groups = { "ut" })
public void testTestStepEncodeXmlStatusFailed() {
    TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>(), true);
    step.setFailed(true);
    TestStep encodedTestStep = step.encode("xml");
    Assert.assertTrue(encodedTestStep.getFailed());
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 53 with TestStep

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

the class TestTestStep method testPasswordMaskingXmlEncodedMainStepWithSpecialCharacters.

@Test(groups = { "ut" })
public void testPasswordMaskingXmlEncodedMainStepWithSpecialCharacters() {
    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("xml").getName(), "step1 with args: (bar, ******)");
    Assert.assertEquals(action.encode("xml").getName(), "action in step1 with args: (foo, ******)");
    Assert.assertEquals(message.encode("xml").getName(), "everything OK on ******");
    Assert.assertEquals(substep.encode("xml").getName(), "substep with args: (******)");
    Assert.assertEquals(step.encode("xml").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 TestStep

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

the class TestTestStep method testSnapshotRenamingNoRandom.

/**
 * Check case where random part of attachment is removed
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testSnapshotRenamingNoRandom() throws IOException {
    SeleniumTestsContextManager.getThreadContext().setRandomInAttachmentNames(false);
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    ScreenShot screenshot = new ScreenShot();
    File tmpImgFile = File.createTempFile("img", ".png");
    File tmpHtmlFile = File.createTempFile("html", ".html");
    screenshot.setOutputDirectory(tmpImgFile.getParent());
    screenshot.setLocation("http://mysite.com");
    screenshot.setTitle("mysite");
    screenshot.setImagePath(tmpImgFile.getName());
    screenshot.setHtmlSourcePath(tmpHtmlFile.getName());
    step.addSnapshot(new Snapshot(screenshot, "main", SnapshotCheckType.TRUE), 0, null);
    Assert.assertEquals(step.getSnapshots().get(0).getScreenshot().getImagePath(), "N-A_0-1_step1-.png");
    Assert.assertEquals(step.getSnapshots().get(0).getScreenshot().getHtmlSourcePath(), "N-A_0-1_step1-.html");
    tmpImgFile.deleteOnExit();
    tmpHtmlFile.deleteOnExit();
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Snapshot(com.seleniumtests.reporter.logger.Snapshot) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) File(java.io.File) GenericFile(com.seleniumtests.reporter.logger.GenericFile) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 55 with TestStep

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

the class TestTestStep method testTestStepEncodeXmlHarKept.

@Test(groups = { "ut" })
public void testTestStepEncodeXmlHarKept() throws IOException {
    Har har = new Har(new HarLog());
    har.getLog().addPage(new HarPage("title", "a title"));
    HarCapture cap = new HarCapture(har, "main");
    TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>(), true);
    step.setHarCaptures(Arrays.asList(cap));
    TestStep encodedTestStep = step.encode("xml");
    Assert.assertEquals(encodedTestStep.getHarCaptures().get(0), cap);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) HarLog(net.lightbody.bmp.core.har.HarLog) Har(net.lightbody.bmp.core.har.Har) HarCapture(com.seleniumtests.reporter.logger.HarCapture) HarPage(net.lightbody.bmp.core.har.HarPage) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

TestStep (com.seleniumtests.reporter.logger.TestStep)190 Test (org.testng.annotations.Test)148 GenericTest (com.seleniumtests.GenericTest)120 ArrayList (java.util.ArrayList)80 TestAction (com.seleniumtests.reporter.logger.TestAction)47 File (java.io.File)37 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)25 Snapshot (com.seleniumtests.reporter.logger.Snapshot)24 ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)19 TestMessage (com.seleniumtests.reporter.logger.TestMessage)16 GenericFile (com.seleniumtests.reporter.logger.GenericFile)15 MockitoTest (com.seleniumtests.MockitoTest)12 HashMap (java.util.HashMap)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 ITestResult (org.testng.ITestResult)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 Uft (com.seleniumtests.connectors.extools.Uft)8 DriverExceptions (com.seleniumtests.customexception.DriverExceptions)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)7 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)6