Search in sources :

Example 36 with SeleniumRobotSnapshotServerConnector

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

the class TestSeleniumRobotSnapshotServerConnector method testCreateSessionServerInactive.

@Test(groups = { "ut" })
public void testCreateSessionServerInactive() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = configureNotAliveConnection();
    connector.createSession("Session1");
    PowerMockito.verifyStatic(Unirest.class, never());
    Unirest.post(ArgumentMatchers.contains(SeleniumRobotSnapshotServerConnector.SESSION_API_URL));
}
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 37 with SeleniumRobotSnapshotServerConnector

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

the class TestSeleniumRobotSnapshotServerConnector method testAddNoTestStepToTestCase.

@Test(groups = { "ut" })
public void testAddNoTestStepToTestCase() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = configureMockedSnapshotServerConnection();
    Integer sessionId = connector.createSession("Session1");
    Integer testCaseId = connector.createTestCase("Test 1");
    Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
    connector.addTestStepsToTestCases(new ArrayList<>(), testCaseInSessionId);
    PowerMockito.verifyStatic(Unirest.class, never());
    Unirest.patch(ArgumentMatchers.contains(SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL));
}
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 38 with SeleniumRobotSnapshotServerConnector

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

the class TestSeleniumRobotSnapshotServerConnector method testGetStepListFromTestCase.

@Test(groups = { "ut" })
public void testGetStepListFromTestCase() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = configureMockedSnapshotServerConnection();
    Integer sessionId = connector.createSession("Session1");
    Integer testCaseId = connector.createTestCase("Test 1");
    Integer testCaseInSessionId = connector.createTestCaseInSession(sessionId, testCaseId, "Test 1");
    createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': ['1', '2']}");
    Assert.assertEquals(connector.getStepListFromTestCase(testCaseInSessionId).size(), 2);
    Assert.assertEquals(connector.getStepListFromTestCase(testCaseInSessionId).get(0), "1");
}
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 39 with SeleniumRobotSnapshotServerConnector

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

the class TestSeleniumRobotSnapshotServerConnector method testGetComparisonResultNotCompleted.

/**
 * when comparison is not completed, do not interfere with result => returns true
 * @throws UnirestException
 */
@Test(groups = { "ut" })
public void testGetComparisonResultNotCompleted() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = spy(configureMockedSnapshotServerConnection());
    createServerMock("GET", SeleniumRobotSnapshotServerConnector.TESTCASEINSESSION_API_URL + "15", 200, "{'testSteps': [], 'completed': false, 'isOkWithSnapshots': 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.SUCCESS);
    // no computing error message
    Assert.assertTrue(errorMessage.toString().isEmpty());
}
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 40 with SeleniumRobotSnapshotServerConnector

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

the class TestSeleniumRobotSnapshotServerConnector method testCreateVersionInError.

@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testCreateVersionInError() throws UnirestException {
    SeleniumRobotSnapshotServerConnector connector = configureMockedSnapshotServerConnection();
    // reset to be sure it's recreated
    connector.setVersionId(null);
    HttpRequest<HttpRequest> req = createServerMock("POST", SeleniumRobotSnapshotServerConnector.VERSION_API_URL, 200, "{'id': '9'}", "body");
    when(req.asString()).thenThrow(UnirestException.class);
    connector.createVersion();
}
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)

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