Search in sources :

Example 21 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestBrowserExtension method testCreateExtensionWithoutOptions.

/**
 * Test when options do not define extension parameters
 */
@Test(groups = "ut")
public void testCreateExtensionWithoutOptions() {
    Map<String, TestVariable> options = new HashMap<>();
    options.put("extension0.path", new TestVariable("extension0.path", "/home/test/ext.crx"));
    List<BrowserExtension> extensions = BrowserExtension.getExtensions(options);
    Assert.assertEquals(extensions.size(), 1);
    Assert.assertEquals(extensions.get(0).getExtensionPath(), new File("/home/test/ext.crx"));
    Assert.assertEquals(extensions.get(0).getOptions().size(), 0);
}
Also used : HashMap(java.util.HashMap) BrowserExtension(com.seleniumtests.browserfactory.BrowserExtension) TestVariable(com.seleniumtests.core.TestVariable) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 22 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testFetchVariableFailed.

/**
 * get variables failes with error on server side
 * @throws UnirestException
 */
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testFetchVariableFailed() throws UnirestException {
    configureMockedVariableServerConnection();
    createServerMock(SERVER_URL, "GET", SeleniumRobotVariableServerConnector.VARIABLE_API_URL, 404, "{}");
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    Map<String, TestVariable> variables = connector.getVariables();
    Assert.assertEquals(variables.get("key1").getValue(), "value1");
    Assert.assertEquals(variables.get("key2").getValue(), "value2");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableRecreateExistingVariable.

/**
 * Variable is re-created when user has changed the value of a non-custom variable
 * @throws UnirestException
 */
@Test(groups = { "ut" })
public void testVariableRecreateExistingVariable() throws UnirestException {
    configureMockedVariableServerConnection();
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    TestVariable existingVariable = new TestVariable(12, "key", "value", false, "key");
    TestVariable variable = connector.upsertVariable(existingVariable, true);
    PowerMockito.verifyStatic(Unirest.class);
    Unirest.post(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
    Assert.assertEquals(variable.getValue(), "value");
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testFetchVariableWithNetworkError.

@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testFetchVariableWithNetworkError() throws UnirestException {
    configureMockedVariableServerConnection();
    HttpRequest<HttpRequest> req = createServerMock(SERVER_URL, "GET", SeleniumRobotVariableServerConnector.VARIABLE_API_URL, 200, "{}");
    when(req.asString()).thenThrow(UnirestException.class);
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    Map<String, TestVariable> variables = connector.getVariables();
    Assert.assertEquals(variables.get("key1").getValue(), "value1");
    Assert.assertEquals(variables.get("key2").getValue(), "value2");
}
Also used : HttpRequest(kong.unirest.HttpRequest) TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with TestVariable

use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.

the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariableWithServerError.

@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testVariableUpdateExistingVariableWithServerError() throws UnirestException {
    configureMockedVariableServerConnection();
    createServerMock(SERVER_URL, "PATCH", String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 12), 500, "{}");
    SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
    TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
    connector.upsertVariable(existingVariable, true);
}
Also used : TestVariable(com.seleniumtests.core.TestVariable) SeleniumRobotVariableServerConnector(com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

TestVariable (com.seleniumtests.core.TestVariable)72 Test (org.testng.annotations.Test)66 GenericTest (com.seleniumtests.GenericTest)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)38 XmlTest (org.testng.xml.XmlTest)34 ConnectorsTest (com.seleniumtests.ConnectorsTest)19 MockitoTest (com.seleniumtests.MockitoTest)19 ITestResult (org.testng.ITestResult)14 HashMap (java.util.HashMap)13 SeleniumRobotVariableServerConnector (com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 SeleniumTestsContext (com.seleniumtests.core.SeleniumTestsContext)7 File (java.io.File)3 ArrayList (java.util.ArrayList)3 JSONObject (kong.unirest.json.JSONObject)3 BrowserExtension (com.seleniumtests.browserfactory.BrowserExtension)2 ConfigReader (com.seleniumtests.core.config.ConfigReader)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 IOException (java.io.IOException)2 HttpRequest (kong.unirest.HttpRequest)2