use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestPerformanceReporter method testSnapshotComparisonSkipAddTestResult.
@Test(groups = { "it" })
public void testSnapshotComparisonSkipAddTestResult() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR, "addTestResult");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:4321");
SeleniumRobotSnapshotServerConnector server = configureMockedSnapshotServerConnection();
createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'computed': true, 'isOkWithSnapshots': null, 'computingError': 'error'}");
SeleniumTestsContextManager.removeThreadContext();
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// test both files are available
String detailedReportContent1 = readTestMethodPerfFile("snapshots-testAndSubActions");
Assert.assertTrue(detailedReportContent1.contains("<testcase classname=\"com.seleniumtests.it.stubclasses.StubTestClass\" name=\"Step 8: Snapshot comparison\" time=\"0.0\">"));
Assert.assertTrue(detailedReportContent1.contains("<system-out><![CDATA[Test skipped]]></system-out>"));
// -1 means 'skipped' with our reporter
Assert.assertTrue(detailedReportContent1.contains("failures=\"-1\""));
// this file is not re-generated with "snapshot comparison" step, but this not a problem. Important fact is that both files are present
String detailedReportContent2 = readTestMethodPerfFile("testAndSubActions");
Assert.assertTrue(detailedReportContent2.contains("<testcase classname=\"com.seleniumtests.it.stubclasses.StubTestClass\" name=\"Step 6: Test end\""));
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumTestsReporter2 method testSnapshotComparisonKoAddTestResult.
/**
* Check that when snapshot server is used, we see a tab pointing to snapshot comparison results
* Moreover, a red bullet should be visible on summary result when comparison is KO
* 2 results should be presented: one with the result of selenium test, a second one with the result of snapshot comparison.
* Both are the same but second test is there for integration with junit parser so that we can differentiate navigation result from GUI result.
* @throws Exception
*/
@Test(groups = { "it" })
public void testSnapshotComparisonKoAddTestResult() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR, "addTestResult");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:4321");
SeleniumRobotSnapshotServerConnector server = configureMockedSnapshotServerConnection();
createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'computed': true, 'isOkWithSnapshots': false}");
SeleniumTestsContextManager.removeThreadContext();
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// check there are 2 results. first one is the selenium test (OK) and second one is the snapshot comparison (KO)
String summaryReport = readSummaryFile();
Assert.assertTrue(summaryReport.contains("<i class=\"fas fa-circle circleFailed\" data-toggle=\"tooltip\" title=\"snapshot comparison failed\"></i><a href='testAndSubActions/TestReport.html' info=\"ok\" "));
Assert.assertTrue(summaryReport.contains("<i class=\"fas fa-circle circleFailed\" data-toggle=\"tooltip\" title=\"snapshot comparison failed\"></i><a href='snapshots-testAndSubActions/TestReport.html' info=\"ko\""));
String detailedReportContent = readTestMethodResultFile("snapshots-testAndSubActions");
// tabs are shown
Assert.assertTrue(detailedReportContent.contains("<div id=\"tabs\" style=\"display: block;\" >"));
// failed step has been added for comparison
Assert.assertTrue(detailedReportContent.contains("<div class=\"message-error\">Comparison failed: </div>"));
Assert.assertTrue(detailedReportContent.matches(".*<div class=\"box collapsed-box failed\">.*?<i class=\"fas fa-plus\"></i></button><span class=\"step-title\"> Snapshot comparison.*"));
// snapshot tab not active
Assert.assertTrue(detailedReportContent.contains("<a class=\"nav-link tab-failed \" id=\"snapshot-tab\" data-toggle=\"tab\" href=\"#snapshots\" role=\"tab\" aria-controls=\"profile\" aria-selected=\"false\">Snapshots</a>"));
// check execution logs contains the exception (but not logs)
Assert.assertTrue(detailedReportContent.contains("<div class=\"message-error\"><div>class com.seleniumtests.customexception.ScenarioException: Snapshot comparison failed</div>"));
// iframe present with the right test case id
Assert.assertTrue(detailedReportContent.contains("<iframe src=\"http://localhost:4321/snapshot/compare/stepList/15/?header=true\" id=\"snapshot-iframe\" frameborder=\"0\"></iframe>"));
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumTestsReporter2 method testReportDoesNotContainStepImageWithoutReference.
/**
* Check step state is not displayed when reference image does not exist on server
* @throws Exception
*/
@Test(groups = { "it" })
public void testReportDoesNotContainStepImageWithoutReference() throws Exception {
try {
System.setProperty(SeleniumTestsContext.VIDEO_CAPTURE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS, "true");
System.setProperty(SeleniumTestsContext.TEST_RETRY_COUNT, "0");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:4321");
SeleniumRobotSnapshotServerConnector server = configureMockedSnapshotServerConnection();
// simulate the case where a reference exists
createServerMock("GET", SeleniumRobotSnapshotServerConnector.STEP_REFERENCE_API_URL + "17/", 404, createImageFromResource("tu/ffLogo1.png"));
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForDriverTest" }, ParallelMode.METHODS, new String[] { "testDriverShortKo" });
// read 'testDriver' report. This contains calls to HtmlElement actions
String detailedReportContent1 = readTestMethodResultFile("testDriverShortKo");
// reference and current state should be displayed
Assert.assertFalse(detailedReportContent1.matches(".* class\\=\"step-title\"> _writeSomethingOnNonExistentElement - .*" + "at com\\.seleniumtests\\.it\\.driver\\.support\\.pages\\.DriverTestPage\\._writeSomethingOnNonExistentElement\\(DriverTestPage\\.java.*?" + "<div class\\=\"row\">" + "<div class\\=\"message-snapshot col\"><div class\\=\"text-center\">" + "<a href\\=\"#\" onclick\\=\"\\$\\('#imagepreview'\\).*" + "<img id.*" + // the current state
"<div class\\=\"text-center\">Step beginning state</div>" + "<div class\\=\"text-center font-weight-lighter\"></div>.*" + "<div class\\=\"message-snapshot col\"><div class\\=\"text-center\">.*" + "<img id.*" + // the reference
"<div class\\=\"text-center\">Valid-reference</div>.*"));
// only one extraction of step state is presented (the one for failed step)
Assert.assertEquals(StringUtils.countMatches(detailedReportContent1, "Step beginning state</div>"), 0);
} finally {
System.clearProperty(SeleniumTestsContext.VIDEO_CAPTURE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS);
System.clearProperty(SeleniumTestsContext.TEST_RETRY_COUNT);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumTestsReporter2 method testSnapshotComparisonKoChangeTestResult.
/**
* Check that when snapshot server is used, we see a tab pointing to snapshot comparison results
* Moreover, a red bullet should be visible on summary result when comparison is KO
* Result is KO as behavior is 'changeTestResult'
* @throws Exception
*/
@Test(groups = { "it" })
public void testSnapshotComparisonKoChangeTestResult() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR, "changeTestResult");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:4321");
SeleniumRobotSnapshotServerConnector server = configureMockedSnapshotServerConnection();
createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'computed': true, 'isOkWithSnapshots': false}");
SeleniumTestsContextManager.removeThreadContext();
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// check result is KO (due to option 'changeTestResult') and comparison result is shown through red bullet (comparison KO)
String summaryReport = readSummaryFile();
Assert.assertTrue(summaryReport.contains("<i class=\"fas fa-circle circleFailed\" data-toggle=\"tooltip\" title=\"snapshot comparison failed\">"));
Assert.assertTrue(summaryReport.contains("info=\"ko\" data-toggle=\"tooltip\""));
String detailedReportContent = readTestMethodResultFile("testAndSubActions");
// tabs are shown
Assert.assertTrue(detailedReportContent.contains("<div id=\"tabs\" style=\"display: block;\" >"));
// failed step has been added for comparison
Assert.assertTrue(detailedReportContent.contains("<div class=\"message-error\">Comparison failed: </div>"));
Assert.assertTrue(detailedReportContent.matches(".*<div class=\"box collapsed-box failed\">.*?<i class=\"fas fa-plus\"></i></button><span class=\"step-title\"> Snapshot comparison.*"));
// snapshot tab not active
Assert.assertTrue(detailedReportContent.contains("<a class=\"nav-link tab-failed \" id=\"snapshot-tab\" data-toggle=\"tab\" href=\"#snapshots\" role=\"tab\" aria-controls=\"profile\" aria-selected=\"false\">Snapshots</a>"));
// iframe present with the right test case id
Assert.assertTrue(detailedReportContent.contains("<iframe src=\"http://localhost:4321/snapshot/compare/stepList/15/?header=true\" id=\"snapshot-iframe\" frameborder=\"0\"></iframe>"));
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumTestsReporter2 method testSnapshotComparisonSkipAddTestResult.
/**
* Check that when snapshot server is used, we see a tab pointing to snapshot comparison results
* Moreover, a red bullet should be visible on summary result when comparison is KO
* 2 results should be presented: one with the result of selenium test, a second one with the result of snapshot comparison.
* Both are the same but second test is there for integration with junit parser so that we can differentiate navigation result from GUI result.
* @throws Exception
*/
@Test(groups = { "it" })
public void testSnapshotComparisonSkipAddTestResult() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR, "addTestResult");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:4321");
SeleniumRobotSnapshotServerConnector server = configureMockedSnapshotServerConnection();
createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'computed': true, 'isOkWithSnapshots': null, 'computingError': ['error computing']}");
SeleniumTestsContextManager.removeThreadContext();
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// check there are 2 results. first one is the selenium test (OK) and second one is the snapshot comparison (KO)
String summaryReport = readSummaryFile();
Assert.assertTrue(summaryReport.contains("<i class=\"fas fa-circle circleSkipped\" data-toggle=\"tooltip\" title=\"snapshot comparison skipped\"></i><a href='testAndSubActions/TestReport.html' info=\"ok\" "));
Assert.assertTrue(summaryReport.contains("<i class=\"fas fa-circle circleSkipped\" data-toggle=\"tooltip\" title=\"snapshot comparison skipped\"></i><a href='snapshots-testAndSubActions/TestReport.html' info=\"skipped\""));
String detailedReportContent = readTestMethodResultFile("snapshots-testAndSubActions");
// tabs are shown
Assert.assertTrue(detailedReportContent.contains("<div id=\"tabs\" style=\"display: block;\" >"));
// failed step has been added for comparison
Assert.assertTrue(detailedReportContent.contains("<div class=\"message-error\">Comparison skipped: "error computing"</div>"));
Assert.assertTrue(detailedReportContent.matches(".*<div class=\"box collapsed-box failed\">.*?<i class=\"fas fa-plus\"></i></button><span class=\"step-title\"> Snapshot comparison.*"));
// snapshot tab not active
Assert.assertTrue(detailedReportContent.contains("<a class=\"nav-link tab-skipped \" id=\"snapshot-tab\" data-toggle=\"tab\" href=\"#snapshots\" role=\"tab\" aria-controls=\"profile\" aria-selected=\"false\">Snapshots</a>"));
// iframe present with the right test case id
Assert.assertTrue(detailedReportContent.contains("<iframe src=\"http://localhost:4321/snapshot/compare/stepList/15/?header=true\" id=\"snapshot-iframe\" frameborder=\"0\"></iframe>"));
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_RECORD_RESULTS);
}
}
Aggregations