use of com.seleniumtests.connectors.selenium.SeleniumGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumGridConnector method testIsGridActiveWithGridInError.
@Test(groups = { "ut" })
public void testIsGridActiveWithGridInError() throws ClientProtocolException, IOException, UnirestException {
SeleniumGridConnector connector = new SeleniumGridConnector(SERVER_URL);
createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 500, "some text");
Assert.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumGridConnector method testGetSessionInformationFromGridWithSecondDriver.
/**
* @throws UnsupportedOperationException
* @throws IOException
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testGetSessionInformationFromGridWithSecondDriver() throws UnsupportedOperationException, IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, UnirestException {
createServerMock("GET", "/grid/api/testsession/", 200, "{'proxyId': 'http://localhost:43210'}");
// prepare app file
((DesiredCapabilities) capabilities).setCapability(CapabilityType.BROWSER_NAME, "firefox");
((DesiredCapabilities) capabilities).setCapability(CapabilityType.BROWSER_VERSION, "50.0");
// prepare response
InputStream is = new StringInputStream("{'proxyId':'proxy//node:0'}");
when(entity.getContent()).thenReturn(is);
SeleniumGridConnector connector = spy(new SeleniumGridConnector(SERVER_URL));
// 2 drivers created inside the same test
connector.getSessionInformationFromGrid(driver);
connector.getSessionInformationFromGrid(driver2);
// issue #242: check sessionId is set only once when first driver is created
verify(connector).setSessionId(any(SessionId.class));
Assert.assertEquals(connector.getNodeUrl(), "http://localhost:43210");
}
use of com.seleniumtests.connectors.selenium.SeleniumGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumGridConnector method testIsGridActiveWithGridNotPresent.
@Test(groups = { "ut" })
public void testIsGridActiveWithGridNotPresent() throws ClientProtocolException, IOException, UnirestException {
SeleniumGridConnector connector = new SeleniumGridConnector(SERVER_URL);
when(Unirest.get(SERVER_URL + SeleniumGridConnector.CONSOLE_SERVLET)).thenReturn(getRequest);
when(getRequest.asString()).thenThrow(UnirestException.class);
Assert.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridActiveWithoutNodes.
/**
* Check that we get false if the grid is ACTIVE and no node is present
* @throws ClientProtocolException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridActiveWithoutNodes() throws ClientProtocolException, IOException {
String hubStatus = "{" + " \"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.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumGridConnector 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());
}
Aggregations