use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestTestTasks method testExecuteCommandNotUsed.
/**
* Test when the grid connector is not initialized
* When grid connector does not return any sessionId, it's not active
* @param testNGCtx
*/
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testExecuteCommandNotUsed(final ITestContext testNGCtx) {
SeleniumGridConnector gridConnector = spy(new SeleniumRobotGridConnector("http://localhost:4444/hub/wd"));
doReturn("hello guys").when(gridConnector).executeCommand("echo", "hello");
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.executeCommand("echo", "hello");
} finally {
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestTestTasks method testKillProcessGridNotUsed.
/**
* Test when the grid connector is not initialized
* When grid connector does not return any sessionId, it's not active
* @param testNGCtx
*/
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testKillProcessGridNotUsed(final ITestContext testNGCtx) {
SeleniumGridConnector gridConnector = spy(new SeleniumRobotGridConnector("http://localhost:4444/hub/wd"));
doNothing().when(gridConnector).killProcess("some_process");
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.killProcess("some_process");
verify(gridConnector).killProcess("some_process");
} finally {
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestTestTasks method testExecuteCommandGridWithTimeout.
@Test(groups = { "ut" })
public void testExecuteCommandGridWithTimeout(final ITestContext testNGCtx) {
SeleniumGridConnector gridConnector = spy(new SeleniumRobotGridConnector("http://localhost:4444/hub/wd"));
gridConnector.setNodeUrl("http://localhost:5555/hub/wd");
doReturn("hello guys").when(gridConnector).executeCommand("echo", 25, "hello");
// 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();
String response = TestTasks.executeCommand("echo", 25, null, "hello");
Assert.assertEquals(response, "hello guys");
} finally {
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
}
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestTestTasks method testKillProcessOtherRunMode.
/**
* Test kill process is not called when not using local or grid mode
* @param testNGCtx
*/
@Test(groups = { "ut" })
public void testKillProcessOtherRunMode(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.killProcess("some_process");
verify(gridConnector, never()).killProcess("some_process");
} 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 testExecuteCommandGrid.
@Test(groups = { "ut" })
public void testExecuteCommandGrid(final ITestContext testNGCtx) {
SeleniumGridConnector gridConnector = spy(new SeleniumRobotGridConnector("http://localhost:4444/hub/wd"));
gridConnector.setNodeUrl("http://localhost:5555/hub/wd");
doReturn("hello guys").when(gridConnector).executeCommand("echo", -1, "hello");
// 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();
String response = TestTasks.executeCommand("echo", "hello");
Assert.assertEquals(response, "hello guys");
} finally {
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
}
}
Aggregations