use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testUndefinedParamOverride.
/**
* Check that unknown parameters in test override the same param in test suite
*/
@Test(groups = { "ut context" })
public void testUndefinedParamOverride(final ITestContext testNGCtx, final XmlTest xmlTest) {
initThreadContext(testNGCtx);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("anOtherParam").getValue(), "value3");
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testPlatformParsingForAndroidFromTest.
/**
* Same test as above except that platform is set on test level, not in system property
* @param testNGCtx
* @param xmlTest
*/
@Test(groups = { "ut context" })
public void testPlatformParsingForAndroidFromTest(final ITestContext testNGCtx, final XmlTest xmlTest) {
try {
xmlTest.addParameter("platform", "Android 5.0");
System.setProperty("deviceName", "");
initThreadContext(testNGCtx);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
Assert.assertEquals(seleniumTestsCtx.getPlatform(), "Android");
Assert.assertEquals(seleniumTestsCtx.getMobilePlatformVersion(), "5.0");
} finally {
xmlTest.getLocalParameters().remove("platform");
System.clearProperty("deviceName");
}
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testTechnicalParameterIsNotAddedToVariables.
@Test(groups = { "ut context" })
public void testTechnicalParameterIsNotAddedToVariables(final ITestContext testNGCtx) {
try {
System.setProperty("browser", "safari");
initThreadContext(testNGCtx);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
Assert.assertNull(seleniumTestsCtx.getConfiguration().get("browser"));
} finally {
System.clearProperty("browser");
}
}
use of com.seleniumtests.core.SeleniumTestsContext in project seleniumRobot by bhecquet.
the class TestTestNGResultUtil method testChangeTestResultWithSnapshot.
private void testChangeTestResultWithSnapshot(String snapshotName, SnapshotCheckType snapshotCheckType, SnapshotComparisonResult comparisonResult) throws IOException {
// create a step with snapshot that should be compared
TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), true);
File tmpImg = File.createTempFile("img", "_with_very_very_very_long_name_to_be_shortened.png");
File tmpHtml = File.createTempFile("html", "_with_very_very_very_long_name_to_be_shortened.html");
ScreenShot screenshot = new ScreenShot();
screenshot.setImagePath("screenshot/" + tmpImg.getName());
screenshot.setHtmlSourcePath("htmls/" + tmpHtml.getName());
FileUtils.copyFile(tmpImg, new File(screenshot.getFullImagePath()));
FileUtils.copyFile(tmpHtml, new File(screenshot.getFullHtmlPath()));
step1.addSnapshot(new Snapshot(screenshot, snapshotName, snapshotCheckType), 1, null);
SeleniumTestsContext context = SeleniumTestsContextManager.getThreadContext();
context.getTestStepManager().logTestStep(step1);
when(testResult.getStatus()).thenReturn(ITestResult.SUCCESS);
when(testResult.getAttribute("testContext")).thenReturn(context);
// make this test successful, it will be changed to failed
List<ITestNGMethod> methods = new ArrayList<>();
methods.add(testNGMethod);
when(passedTests.getAllMethods()).thenReturn(methods);
// be sure we will do comparison
SeleniumTestsContextManager.getGlobalContext().setSeleniumRobotServerCompareSnapshotBehaviour("changeTestResult");
SeleniumTestsContextManager.getGlobalContext().setSeleniumRobotServerActive(true);
SeleniumTestsContextManager.getGlobalContext().setSeleniumRobotServerCompareSnapshot(true);
PowerMockito.when(SeleniumRobotSnapshotServerConnector.getInstance()).thenReturn(snapshotServerConnector);
when(snapshotServerConnector.checkSnapshotHasNoDifferences(any(Snapshot.class), anyString(), anyString())).thenReturn(comparisonResult);
TestNGResultUtils.changeTestResultWithSnapshotComparison(testResult);
}
Aggregations