Search in sources :

Example 11 with SeleniumGridConnector

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

the class TestSeleniumGridConnector method testIsGridActiveWithGridPresent.

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

Example 12 with SeleniumGridConnector

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

the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridActiveInvalidStatus.

/**
 * Check that we get false if the status returned by grid is invalid (no JSON)
 * @throws ClientProtocolException
 * @throws IOException
 * @throws UnirestException
 */
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridActiveInvalidStatus() throws ClientProtocolException, IOException {
    String hubStatus = "null";
    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 SeleniumGridConnector

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

the class TestSeleniumRobotGridConnector method testIsGridActiveWithGridNotPresent.

@Test(groups = { "ut" })
public void testIsGridActiveWithGridNotPresent() throws ClientProtocolException, IOException {
    SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
    when(Unirest.get(SERVER_URL + SeleniumGridConnector.CONSOLE_SERVLET)).thenReturn(getRequest);
    when(getRequest.asString()).thenThrow(UnirestException.class);
    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 SeleniumGridConnector

use of com.seleniumtests.connectors.selenium.SeleniumGridConnector 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 15 with SeleniumGridConnector

use of com.seleniumtests.connectors.selenium.SeleniumGridConnector 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)

Aggregations

SeleniumGridConnector (com.seleniumtests.connectors.selenium.SeleniumGridConnector)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)28 Test (org.testng.annotations.Test)28 SeleniumRobotGridConnector (com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector)19 ConnectorsTest (com.seleniumtests.ConnectorsTest)18 GenericTest (com.seleniumtests.GenericTest)13 XmlTest (org.testng.xml.XmlTest)13 MockitoTest (com.seleniumtests.MockitoTest)10 SessionId (org.openqa.selenium.remote.SessionId)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 ScenarioException (com.seleniumtests.customexception.ScenarioException)3 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)3 ITestResult (org.testng.ITestResult)3 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 InputStream (java.io.InputStream)2 StringInputStream (org.apache.tools.ant.filters.StringInputStream)2 SessionNotCreatedException (org.openqa.selenium.SessionNotCreatedException)2 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)2 SeleniumGridNodeNotAvailable (com.seleniumtests.customexception.SeleniumGridNodeNotAvailable)1 SeleniumRobotLogger (com.seleniumtests.util.logging.SeleniumRobotLogger)1