use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class SeleniumRobotServerTestRecorder method recordResults.
private void recordResults(SeleniumRobotSnapshotServerConnector serverConnector, Map<ITestContext, Set<ITestResult>> resultSet) {
for (Entry<ITestContext, Set<ITestResult>> entry : resultSet.entrySet()) {
List<ITestResult> methodResults = entry.getValue().stream().sorted((r1, r2) -> Long.compare(r1.getStartMillis(), r2.getStartMillis())).collect(Collectors.toList());
// test case in seleniumRobot naming
for (ITestResult testResult : methodResults) {
// do not record this result twice if it's already recorded
if (TestNGResultUtils.isSeleniumServerReportCreated(testResult) || // NoMoreRetry is set to false when test is being retried => we do not want to record a temp result, only the last one
(TestNGResultUtils.getNoMoreRetry(testResult) != null && !TestNGResultUtils.getNoMoreRetry(testResult))) {
continue;
}
// issue #81: recreate test context from this context (due to multithreading, this context may be null if parallel testing is used)
SeleniumTestsContextManager.setThreadContextFromTestResult(entry.getKey(), testResult);
// skipped tests has never been executed and so attribute (set in TestListener) has not been applied
String testName = getTestCaseName(testResult);
// get sessionId from context
Integer sessionId = TestNGContextUtils.getTestSessionCreated(entry.getKey());
// record test case
Integer testCaseId = serverConnector.createTestCase(testName);
Integer testCaseInSessionId = serverConnector.createTestCaseInSession(sessionId, testCaseId, getTestName(testResult));
serverConnector.addLogsToTestCaseInSession(testCaseInSessionId, generateExecutionLogs(testResult).toString());
List<TestStep> testSteps = TestNGResultUtils.getSeleniumRobotTestContext(testResult).getTestStepManager().getTestSteps();
if (testSteps == null) {
continue;
}
recordSteps(serverConnector, sessionId, testCaseInSessionId, testSteps, testResult);
logger.info(String.format("Snapshots has been recorded with TestCaseSessionId: %d", testCaseInSessionId));
TestNGResultUtils.setSnapshotTestCaseInSessionId(testResult, testCaseInSessionId);
TestNGResultUtils.setSeleniumServerReportCreated(testResult, true);
}
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class SeleniumRobotServerTestRecorder method recordTestSession.
public void recordTestSession(ITestContext testContext) {
SeleniumRobotSnapshotServerConnector serverConnector = getServerConnector();
if (TestNGContextUtils.getTestSessionCreated(testContext) == null) {
Integer sessionId = serverConnector.createSession(testContext.getName());
TestNGContextUtils.setTestSessionCreated(testContext, sessionId);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testCreateSnapshotNull3.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testCreateSnapshotNull3() 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(screenshot.getFullImagePath()).thenReturn(null);
connector.createSnapshot(snapshot, sessionId, testCaseInSessionId, stepResultId);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testCreateSnapshotNull2.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testCreateSnapshotNull2() 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.createSnapshot(snapshot, sessionId, testCaseInSessionId, stepResultId);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotSnapshotServerConnector method testServerNotActive.
@Test(groups = { "ut" })
public void testServerNotActive() {
SeleniumRobotSnapshotServerConnector connector = new SeleniumRobotSnapshotServerConnector(false, SERVER_URL);
Assert.assertFalse(connector.getActive());
}
Aggregations