use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestAndroidCapabilitiesFactory method testCreateCapabilitiesWithRelativeApplicationPath.
/**
* Check mobile test with app relative path => check absolute path is set in capabilities
*/
@Test(groups = { "ut" })
public void testCreateCapabilitiesWithRelativeApplicationPath() {
SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
context.setMobilePlatformVersion("8.0");
context.setPlatform("android");
context.setDeviceName("Samsung Galasy S8");
context.setAppPackage("appPackage");
context.setAppActivity("appActivity");
context.setApp("data/core/app.apk");
DriverConfig config = new DriverConfig(context);
AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
MutableCapabilities capa = capaFactory.createCapabilities();
Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "");
logger.info("app path: " + capa.getCapability("app"));
Assert.assertTrue(capa.getCapability("app").toString().contains("/data/core/app.apk"));
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestAndroidCapabilitiesFactory method testCreateCapabilitiesWithAbsoluteApplicationPath.
/**
* Check mobile test with app relative path => check absolute path is set in capabilities
*/
@Test(groups = { "ut" })
public void testCreateCapabilitiesWithAbsoluteApplicationPath() {
SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
context.setMobilePlatformVersion("8.0");
context.setPlatform("android");
context.setDeviceName("Samsung Galasy S8");
context.setAppPackage("appPackage");
context.setAppActivity("appActivity");
String path = new File("data/core/app.apk").getAbsolutePath();
context.setApp(path);
DriverConfig config = new DriverConfig(context);
AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
MutableCapabilities capa = capaFactory.createCapabilities();
Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "");
Assert.assertEquals(capa.getCapability("app"), path.replace("\\", "/"));
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestAndroidCapabilitiesFactory method testCreateCapabilitiesWithApplicationOldAndroid.
/**
* Check automationName capability with android < 4
*/
@Test(groups = { "ut" })
public void testCreateCapabilitiesWithApplicationOldAndroid() {
SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
context.setMobilePlatformVersion("2.3");
context.setPlatform("android");
context.setDeviceName("Samsung Galasy S1");
context.setAppPackage("appPackage");
context.setAppActivity("appActivity");
context.setFullReset(true);
context.setApp("com.covea.mobileapp");
DriverConfig config = new DriverConfig(context);
AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
MutableCapabilities capa = capaFactory.createCapabilities();
Assert.assertEquals(capa.getCapability(MobileCapabilityType.AUTOMATION_NAME), "Selendroid");
}
use of com.seleniumtests.core.SeleniumTestsContext 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.SeleniumTestsContext 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);
}
}
Aggregations