Search in sources :

Example 46 with TestStep

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();
        }
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) TestStep(com.seleniumtests.reporter.logger.TestStep) DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) TestStepManager(com.seleniumtests.core.TestStepManager) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 47 with TestStep

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: (******)");
}
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 48 with TestStep

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 &quot;&apos;&lt;&gt;&amp;");
    Assert.assertEquals(encodedTestStep.getRootCauseDetails(), "&quot;&apos;&lt;&gt;&amp;");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 49 with TestStep

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: (******)");
}
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 50 with TestStep

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();
}
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)

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