use of com.seleniumtests.core.SeleniumTestsContext 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");
}
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext3 method testVariablesAreGetMultipleTimesWithContextCopy.
/**
* Check that when copying context, it's possible to allow it to retrieve
* variables from server
*
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" })
public void testVariablesAreGetMultipleTimesWithContextCopy(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.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();
// do a parameter retrieving for copied context. Context is copied with
// permitting calls to variable server
SeleniumTestsContext seleniumTestsCtx2 = new SeleniumTestsContext(seleniumTestsCtx);
seleniumTestsCtx2.configureContext(testResult);
// check that variables are kept even if variable server has not been re-called
Assert.assertEquals(seleniumTestsCtx2.getConfiguration().get("key").getValue(), "val1");
// 2 calls, one for each context because we allow variable retrieving when
// copying
verify(variableServer, times(2)).getVariables(0);
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testProxyPreset.
@Test(groups = "ut context")
public void testProxyPreset(final ITestContext testNGCtx, final XmlTest xmlTest) {
SeleniumTestsContextManager.generateApplicationPath(testNGCtx.getCurrentXmlTest().getSuite());
SeleniumTestsContext seleniumContext = new SeleniumTestsContext();
seleniumContext.setCaptureNetwork(false);
seleniumContext.setConfiguration(new HashMap<>());
seleniumContext.setTestConfiguration();
seleniumContext.updateProxyConfig();
Assert.assertEquals(seleniumContext.getWebProxyType(), ProxyType.DIRECT);
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testPlatformParsingForIOSWithoutVersion.
@Test(groups = { "ut context" })
public void testPlatformParsingForIOSWithoutVersion(final ITestContext testNGCtx, final XmlTest xmlTest) {
try {
System.setProperty("platform", "iOS");
System.setProperty("deviceName", "");
initThreadContext(testNGCtx);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
Assert.assertEquals(seleniumTestsCtx.getPlatform(), "iOS");
Assert.assertEquals(seleniumTestsCtx.getMobilePlatformVersion(), null);
} finally {
System.clearProperty("platform");
System.clearProperty("deviceName");
}
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testTestLevelParam2.
/**
* If parameter is defined in test suite and test, the test parameter must override suite parameter
* Here, we check that it's the right test parameter which is get (same parameter defined in several tests with different
* values
*/
@Test(groups = { "ut context" })
public void testTestLevelParam2(final ITestContext testNGCtx, final XmlTest xmlTest) {
initThreadContext(testNGCtx);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("variable1").getValue(), "value1");
}
Aggregations