use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariableWithToken.
@Test(groups = { "ut" })
public void testVariableUpdateExistingVariableWithToken() throws UnirestException {
configureMockedVariableServerConnection();
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", "123");
TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
connector.upsertVariable(existingVariable, true);
verify(variablesRequest, never()).header("Authorization", "Token 123");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testFetchVariable.
@Test(groups = { "ut" })
public void testFetchVariable() throws UnirestException {
configureMockedVariableServerConnection();
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");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext3 method testGridConnectorIsCopiedWithContextCopy.
/**
* issue #291: Check that when copying context, grid connector is also copied so
* that it can be possible to re-use a driver created in \@BeforeMethod
*
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" })
public void testGridConnectorIsCopiedWithContextCopy(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
Map<String, TestVariable> variables = new HashMap<>();
variables.put("key", new TestVariable("key", "val1"));
try {
System.setProperty(SeleniumTestsContext.WEB_DRIVER_GRID, "http://localhost:4321/wd/hub");
System.setProperty(SeleniumTestsContext.RUN_MODE, "grid");
System.setProperty(SeleniumTestsContext.BROWSER, "chrome");
createGridHubMockWithNodeOK();
ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
initThreadContext(testNGCtx, "myTest", testResult);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
seleniumTestsCtx.configureContext(testResult);
WebUIDriver.getWebDriver(true);
// do a parameter retrieving for copied context
SeleniumTestsContext seleniumTestsCtx2 = new SeleniumTestsContext(seleniumTestsCtx, false);
Assert.assertEquals(seleniumTestsCtx2.getSeleniumGridConnector(), seleniumTestsCtx.getSeleniumGridConnector());
} finally {
System.clearProperty(SeleniumTestsContext.WEB_DRIVER_GRID);
System.clearProperty(SeleniumTestsContext.RUN_MODE);
System.clearProperty(SeleniumTestsContext.BROWSER);
}
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext3 method testVariablesFromVariableServer.
/**
* Check variables can be get from variable server
*
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" })
public void testVariablesFromVariableServer(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
Map<String, TestVariable> variables = new HashMap<>();
variables.put("key1", new TestVariable("key1", "val1"));
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:1234");
PowerMockito.whenNew(SeleniumRobotVariableServerConnector.class).withArguments(eq(true), eq("http://localhost:1234"), anyString(), eq(null)).thenReturn(variableServer);
when(variableServer.isAlive()).thenReturn(true);
when(variableServer.getVariables(0)).thenReturn(variables);
ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
initThreadContext(testNGCtx, "myTest", testResult);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
seleniumTestsCtx.configureContext(testResult);
Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key1").getValue(), "val1");
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext3 method testUserDefinedParamOverridesVariableServer.
/**
* If parameter is defined in variable server and as JVM parameter (user
* defined), the user defined parameter must be used
*
* @throws Exception
*/
@Test(groups = { "ut" })
public void testUserDefinedParamOverridesVariableServer(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
Map<String, TestVariable> variables = new HashMap<>();
variables.put("key1", new TestVariable("key1", "val1"));
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:1234");
PowerMockito.whenNew(SeleniumRobotVariableServerConnector.class).withArguments(eq(true), eq("http://localhost:1234"), anyString(), eq(null)).thenReturn(variableServer);
when(variableServer.isAlive()).thenReturn(true);
when(variableServer.getVariables(0)).thenReturn(variables);
System.setProperty("key1", "userValue");
ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
initThreadContext(testNGCtx, "myTest", testResult);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key1").getValue(), "userValue");
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
System.clearProperty("key1");
}
}
Aggregations