use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumTestsReporter2 method testSnapshotNoComparisonDisplayOnly.
/**
* Test case where no snapshot has been sent to server, 'snapshot comparison' step should be green with message stating that no picture has been processed
* @throws Exception
*/
@Test(groups = { "it" })
public void testSnapshotNoComparisonDisplayOnly() throws Exception {
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_COMPARE_SNAPSHOT_BEHAVIOUR, "displayOnly");
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': []}");
SeleniumTestsContextManager.removeThreadContext();
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// check result is ok and comparison result is shown through blue bullet (no comparison to do)
String summaryReport = readSummaryFile();
Assert.assertTrue(summaryReport.contains("<i class=\"fas fa-circle circleSkipped\" data-toggle=\"tooltip\" title=\"snapshot comparison skipped\">"));
Assert.assertTrue(summaryReport.contains("info=\"ok\" data-toggle=\"tooltip\""));
String detailedReportContent = readTestMethodResultFile("testAndSubActions");
// tabs are shown
Assert.assertTrue(detailedReportContent.contains("<div id=\"tabs\" style=\"display: block;\" >"));
// successful step has been added for comparison
Assert.assertTrue(detailedReportContent.contains("<div class=\"message-log\">No comparison to do (no snapshots)</div>"));
Assert.assertTrue(detailedReportContent.matches(".*<div class=\"box collapsed-box success\">.*?<i class=\"fas fa-plus\"></i></button><span class=\"step-title\"> Snapshot comparison.*"));
// snapshot tab active / skipped
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);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumTestsReporter2 method testReportDoeNotContainStepReferenceForFailedStepWhenVideoDisabled.
@Test(groups = { "it" })
public void testReportDoeNotContainStepReferenceForFailedStepWhenVideoDisabled() throws Exception {
try {
System.setProperty(SeleniumTestsContext.VIDEO_CAPTURE, "false");
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/", 200, 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");
// no image reference
Assert.assertEquals(StringUtils.countMatches(detailedReportContent1, "Step beginning state</div>"), 0);
// check step beginning state is not present with valid path
Assert.assertFalse(detailedReportContent1.contains("src=\"screenshots/testDriverShortKo_4-1__writeSomethingOnNonExistent-ideo-1.jpg\""));
} 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 TestSeleniumRobotSnapshotServerConnector method testCreateSnapshotLongName.
/**
* snapshot name is limited to 100 chars by server, check we strip it
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testCreateSnapshotLongName() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
MultipartBody request = (MultipartBody) createServerMock("POST", SeleniumRobotSnapshotServerConnector.SNAPSHOT_API_URL, 200, "{'id': '14'}", "body");
when(snapshot.getName()).thenReturn("snapshot" + StringUtils.repeat("-", 93));
Integer sessionId = connector.createSession("Session1");
Integer testCaseId = connector.createTestCase("Test 1");
Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
Integer testStepId = connector.createTestStep("Step 1", testCaseInSessionId);
Integer stepResultId = connector.recordStepResult(true, "", 1, sessionId, testCaseInSessionId, testStepId);
Integer snapshotId = connector.createSnapshot(snapshot, sessionId, testCaseInSessionId, stepResultId);
verify(request).field("name", ("snapshot" + StringUtils.repeat("-", 92)));
// check prerequisites has been created
Assert.assertEquals((int) sessionId, 13);
Assert.assertEquals((int) snapshotId, 14);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testGetComparisonResultNotAvailable.
/**
* when comparison is not available, do not interfere with result => returns true
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testGetComparisonResultNotAvailable() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'completed': true}");
Integer sessionId = connector.createSession("Session1");
Integer testCaseId = connector.createTestCase("Test 1");
Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
StringBuilder errorMessage = new StringBuilder();
int comparisonResult = connector.getTestCaseInSessionComparisonResult(testCaseInSessionId, errorMessage);
Assert.assertEquals(comparisonResult, ITestResult.SKIP);
// no computing error message
Assert.assertTrue(errorMessage.toString().isEmpty());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testCreateStepReferenceSnapshotNull2.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testCreateStepReferenceSnapshotNull2() throws UnirestException {
SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
Integer sessionId = connector.createSession("Session1");
Integer testCaseId = connector.createTestCase("Test 1");
Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
Integer testStepId = connector.createTestStep("Step 1", testCaseInSessionId);
Integer stepResultId = connector.recordStepResult(true, "", 1, sessionId, testCaseInSessionId, testStepId);
when(snapshot.getScreenshot()).thenReturn(null);
connector.createStepReferenceSnapshot(snapshot, stepResultId);
}
Aggregations