Search in sources :

Example 11 with SeleniumRobotGridConnector

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

the class TestSeleniumRobotGridConnector method testExecuteCommand.

@Test(groups = { "ut" })
public void testExecuteCommand() throws UnsupportedOperationException, IOException {
    HttpRequestWithBody req = (HttpRequestWithBody) createServerMock("POST", SeleniumRobotGridConnector.NODE_TASK_SERVLET, 200, "foo");
    SeleniumGridConnector connector = new SeleniumRobotGridConnector("http://localhost:4444/wd/hub");
    connector.setSessionId(new SessionId("1234"));
    connector.setNodeUrl("http://localhost:4321");
    Assert.assertEquals(connector.executeCommand("myProcess", "arg1", "arg2"), "foo");
    verify(req).queryString("arg0", "arg1");
    verify(req).queryString("arg1", "arg2");
    verify(req).queryString("name", "myProcess");
    verify(req).queryString("action", "command");
}
Also used : SeleniumRobotGridConnector(com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector) HttpRequestWithBody(kong.unirest.HttpRequestWithBody) SeleniumGridConnector(com.seleniumtests.connectors.selenium.SeleniumGridConnector) SessionId(org.openqa.selenium.remote.SessionId) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with SeleniumRobotGridConnector

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

the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridInactive.

/**
 * Check that we get false if the grid is INACTIVE
 * @throws ClientProtocolException
 * @throws IOException
 * @throws UnirestException
 */
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridInactive() 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\": \"INACTIVE\"\r\n" + "  },\r\n" + "  \"hub\": {\r\n" + "    \"version\": \"3.14.0\",\r\n" + "    \"status\": \"INACTIVE\"\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());
}
Also used : SeleniumRobotGridConnector(com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SeleniumGridConnector(com.seleniumtests.connectors.selenium.SeleniumGridConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with SeleniumRobotGridConnector

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

the class TestSeleniumRobotGridConnector method testIsGridActiveWithGridInError.

@Test(groups = { "ut" })
public void testIsGridActiveWithGridInError() throws ClientProtocolException, IOException {
    SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
    createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 500, "some text");
    Assert.assertFalse(connector.isGridActive());
}
Also used : SeleniumRobotGridConnector(com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector) SeleniumGridConnector(com.seleniumtests.connectors.selenium.SeleniumGridConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with SeleniumRobotGridConnector

use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector 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());
}
Also used : SeleniumRobotGridConnector(com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SeleniumGridConnector(com.seleniumtests.connectors.selenium.SeleniumGridConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 15 with SeleniumRobotGridConnector

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

the class TestSeleniumRobotGridConnector method init.

@BeforeMethod(groups = { "ut" })
private void init() throws ClientProtocolException, IOException {
    PowerMockito.mockStatic(HttpClients.class);
    when(HttpClients.createDefault()).thenReturn(client);
    when(response.getEntity()).thenReturn(entity);
    when(response.getStatusLine()).thenReturn(statusLine);
    when(client.execute((HttpHost) any(), any())).thenReturn(response);
    connector = new SeleniumRobotGridConnector(SERVER_URL + "/wd/hub");
    connector.setNodeUrl("http://localhost:4321");
    connector.setSessionId(new SessionId("1234"));
    gridLogger = spy(connector.getLogger());
    connector.setLogger(gridLogger);
}
Also used : SeleniumRobotGridConnector(com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector) SessionId(org.openqa.selenium.remote.SessionId) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

SeleniumRobotGridConnector (com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector)21 SeleniumGridConnector (com.seleniumtests.connectors.selenium.SeleniumGridConnector)19 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 Test (org.testng.annotations.Test)19 GenericTest (com.seleniumtests.GenericTest)10 MockitoTest (com.seleniumtests.MockitoTest)10 XmlTest (org.testng.xml.XmlTest)10 ConnectorsTest (com.seleniumtests.ConnectorsTest)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 SessionId (org.openqa.selenium.remote.SessionId)6 BeforeMethod (org.testng.annotations.BeforeMethod)2 HttpRequestWithBody (kong.unirest.HttpRequestWithBody)1 SkipException (org.testng.SkipException)1