use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridReplyInError.
/**
* Check that we get false if the server returns code != 200
* @throws ClientProtocolException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridReplyInError() throws ClientProtocolException, IOException {
String hubStatus = "Internal Server Error";
SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 200, "some text");
createServerMock("GET", SeleniumRobotGridConnector.STATUS_SERVLET, 500, hubStatus);
Assert.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testExecuteCommandWithoutNodeUrl.
/**
* Test executing command when node is still unknown (driver not initialized). In this case, ScenarioException must be thrown
* @throws UnsupportedOperationException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testExecuteCommandWithoutNodeUrl() throws UnsupportedOperationException, IOException {
createServerMock("POST", SeleniumRobotGridConnector.NODE_TASK_SERVLET, 200, "foo");
SeleniumGridConnector connector = new SeleniumRobotGridConnector("http://localhost:4444/wd/hub");
connector.executeCommand("myProcess", "arg1");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridActive.
/**
* Check that we get true if the grid is ACTIVE and at least one node is present
* @throws ClientProtocolException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridActive() throws ClientProtocolException, IOException {
String hubStatus = "{" + "\"http:\\u002f\\u002fnode1.company.com:5555\": {\r\n" + " \"busy\": false,\r\n" + " \"lastSessionStart\": \"2018-08-31T08:30:06Z\",\r\n" + " \"version\": \"3.14.0\",\r\n" + " \"usedTestSlots\": 0,\r\n" + " \"testSlots\": 1,\r\n" + " \"status\": \"ACTIVE\"\r\n" + " },\r\n" + " \"hub\": {\r\n" + " \"version\": \"3.14.0\",\r\n" + " \"status\": \"ACTIVE\"\r\n" + " },\r\n" + " \"success\": true\r\n" + "}";
SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 200, "some text");
createServerMock("GET", SeleniumRobotGridConnector.STATUS_SERVLET, 200, hubStatus);
Assert.assertTrue(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestTestTasks method testExecuteCommandOtherRunMode.
/**
* Test kill process is not called when not using local or grid mode
* @param testNGCtx
*/
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testExecuteCommandOtherRunMode(final ITestContext testNGCtx) {
SeleniumGridConnector gridConnector = spy(new SeleniumRobotGridConnector("http://saucelabs:4444/hub/wd"));
PowerMockito.mockStatic(SeleniumGridConnectorFactory.class);
PowerMockito.when(SeleniumGridConnectorFactory.getInstances(Arrays.asList("http://saucelabs:4444/hub/wd"))).thenReturn(Arrays.asList(gridConnector));
try {
System.setProperty(SeleniumTestsContext.RUN_MODE, "saucelabs");
System.setProperty(SeleniumTestsContext.PLATFORM, "windows");
System.setProperty(SeleniumTestsContext.WEB_DRIVER_GRID, "http://saucelabs:4444/hub/wd");
initThreadContext(testNGCtx);
TestTasks.executeCommand("echo", "hello");
} finally {
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.PLATFORM);
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestTestTasks method testGetProcessListGrid.
@Test(groups = { "ut" })
public void testGetProcessListGrid(final ITestContext testNGCtx) {
SeleniumGridConnector gridConnector = spy(new SeleniumRobotGridConnector("http://localhost:4444/hub/wd"));
doReturn(Arrays.asList(10, 20)).when(gridConnector).getProcessList("some_process");
// grid connector is in use only if session Id exists
doReturn(new SessionId("1234")).when(gridConnector).getSessionId();
PowerMockito.mockStatic(SeleniumGridConnectorFactory.class);
PowerMockito.when(SeleniumGridConnectorFactory.getInstances(Arrays.asList("http://localhost:4444/hub/wd"))).thenReturn(Arrays.asList(gridConnector));
try {
System.setProperty(SeleniumTestsContext.RUN_MODE, "grid");
System.setProperty(SeleniumTestsContext.WEB_DRIVER_GRID, "http://localhost:4444/hub/wd");
initThreadContext(testNGCtx);
SeleniumTestsContextManager.getThreadContext().getSeleniumGridConnectors();
TestTasks.getProcessList("some_process");
verify(gridConnector).getProcessList("some_process");
} finally {
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
}
}
Aggregations