Search in sources :

Example 71 with SeleniumRobotSnapshotServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotSnapshotServerConnector method testCheckSnapshotHasNoDifferences.

@Test(groups = { "ut" })
public void testCheckSnapshotHasNoDifferences() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
    // set it directly has it has been reset on creation
    connector.setVersionId(11);
    SnapshotComparisonResult snapshotHasNoDifference = connector.checkSnapshotHasNoDifferences(snapshot, "Test 1", "Step 1");
    // When no difference is found, return true
    Assert.assertEquals(snapshotHasNoDifference, SnapshotComparisonResult.OK);
}
Also used : SeleniumRobotSnapshotServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector) SnapshotComparisonResult(com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector.SnapshotComparisonResult) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 72 with SeleniumRobotSnapshotServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotSnapshotServerConnector method testCreateStepReferenceSnapshotInError.

@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testCreateStepReferenceSnapshotInError() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = configureMockedSnapshotServerConnection();
    HttpRequest<HttpRequest> req = createServerMock("POST", SeleniumRobotSnapshotServerConnector.STEP_REFERENCE_API_URL, 200, "{'id': '9'}", "body");
    when(req.asString()).thenThrow(UnirestException.class);
    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);
    connector.createStepReferenceSnapshot(snapshot, stepResultId);
}
Also used : HttpRequest(kong.unirest.HttpRequest) SeleniumRobotSnapshotServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 73 with SeleniumRobotSnapshotServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotSnapshotServerConnector method testGetStepReferenceSnapshotNotFound.

@Test(groups = { "ut" })
public void testGetStepReferenceSnapshotNotFound() throws UnirestException, IOException {
    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);
    createServerMock("GET", String.format("%s%d/", SeleniumRobotSnapshotServerConnector.STEP_REFERENCE_API_URL, stepResultId), 404, createImageFromResource("tu/ffLogo1.png"));
    File picture = connector.getReferenceSnapshot(stepResultId);
    Assert.assertNull(picture);
}
Also used : SeleniumRobotSnapshotServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector) File(java.io.File) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 74 with SeleniumRobotSnapshotServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotSnapshotServerConnector method testCreateSnapshotServerInactive.

@Test(groups = { "ut" })
public void testCreateSnapshotServerInactive() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = configureNotAliveConnection();
    Integer snapshotId = connector.createSnapshot(snapshot, 1, 1, 1);
    PowerMockito.verifyStatic(Unirest.class, never());
    Unirest.post(ArgumentMatchers.contains(SeleniumRobotSnapshotServerConnector.SNAPSHOT_API_URL));
    Assert.assertNull(snapshotId);
}
Also used : SeleniumRobotSnapshotServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 75 with SeleniumRobotSnapshotServerConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector in project seleniumRobot by bhecquet.

the class TestSeleniumRobotSnapshotServerConnector method testCreateStepResult.

@Test(groups = { "ut" })
public void testCreateStepResult() 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);
    // check prerequisites has been created
    Assert.assertEquals((int) sessionId, 13);
    Assert.assertEquals((int) stepResultId, 17);
}
Also used : SeleniumRobotSnapshotServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

SeleniumRobotSnapshotServerConnector (com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector)113 Test (org.testng.annotations.Test)106 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)86 ConnectorsTest (com.seleniumtests.ConnectorsTest)84 HttpRequest (kong.unirest.HttpRequest)15 SnapshotComparisonResult (com.seleniumtests.connectors.selenium.SeleniumRobotSnapshotServerConnector.SnapshotComparisonResult)6 File (java.io.File)6 Rectangle (org.openqa.selenium.Rectangle)5 MultipartBody (kong.unirest.MultipartBody)4 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)3 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 ReporterTest (com.seleniumtests.it.reporter.ReporterTest)2 StubTestClassForDriverParallelTest (com.seleniumtests.it.stubclasses.StubTestClassForDriverParallelTest)2 Snapshot (com.seleniumtests.reporter.logger.Snapshot)2 TestStep (com.seleniumtests.reporter.logger.TestStep)2 ArrayList (java.util.ArrayList)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ITestContext (org.testng.ITestContext)2 ITestResult (org.testng.ITestResult)2 XmlTest (org.testng.xml.XmlTest)2