Search in sources :

Example 31 with SeleniumTestsContext

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

the class TestNGResultUtils method copy.

/**
 * Copy a TestResult into an other one
 * @param toCopy
 * @return
 * @throws SecurityException
 * @throws NoSuchFieldException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
public static ITestResult copy(ITestResult toCopy, String name, String description) throws NoSuchFieldException, IllegalAccessException {
    Field methodNameField = BaseTestMethod.class.getDeclaredField("m_methodName");
    methodNameField.setAccessible(true);
    ITestNGMethod newMethod = toCopy.getMethod().clone();
    methodNameField.set(newMethod, name);
    newMethod.setDescription(description);
    ITestResult newTestResult = TestResult.newTestResultFrom((TestResult) toCopy, newMethod, toCopy.getTestContext(), toCopy.getStartMillis());
    newTestResult.setEndMillis(toCopy.getEndMillis());
    newTestResult.setThrowable(toCopy.getThrowable());
    newTestResult.setParameters(toCopy.getParameters());
    for (String attributeName : toCopy.getAttributeNames()) {
        newTestResult.setAttribute(attributeName, toCopy.getAttribute(attributeName));
    }
    // reset flags of generated results
    setHtmlReportCreated(newTestResult, false);
    setCustomReportCreated(newTestResult, false);
    setSnapshotComparisonResult(newTestResult, ITestResult.SKIP);
    // create testResult own context
    SeleniumTestsContext newTestContext = new SeleniumTestsContext(getSeleniumRobotTestContext(toCopy), false);
    newTestContext.createTestSpecificOutputDirectory(newTestResult);
    setSeleniumRobotTestContext(newTestResult, newTestContext);
    // change name
    setTestMethodName(newTestResult, getTestName(newTestResult));
    setUniqueTestName(newTestResult, newTestContext.getRelativeOutputDir());
    return newTestResult;
}
Also used : Field(java.lang.reflect.Field) SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) ITestResult(org.testng.ITestResult) ITestNGMethod(org.testng.ITestNGMethod)

Example 32 with SeleniumTestsContext

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

the class TestAndroidCapabilitiesFactory method testCreateDefaultChromeCapabilities.

/**
 * Check default behaviour
 */
@Test(groups = { "ut" })
public void testCreateDefaultChromeCapabilities() {
    SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
    context.setBrowser(BrowserType.CHROME.toString());
    context.setMobilePlatformVersion("8.0");
    context.setPlatform("android");
    context.setDeviceName("Samsung Galasy S8");
    context.setApp("");
    DriverConfig config = new DriverConfig(context);
    AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
    MutableCapabilities capa = capaFactory.createCapabilities();
    Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), BrowserType.CHROME.toString().toLowerCase());
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.AUTOMATION_NAME), "Appium");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_NAME), "android");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_VERSION), "8.0");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.DEVICE_NAME), "Samsung Galasy S8");
    Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
    // from exampleConfigGenericParams.xml when tu.xml is executed, else, null
    Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_PACKAGE), "com.infotel.mobile");
    // from exampleConfigGenericParams.xml when tu.xml is executed, else, null
    Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_ACTIVITY), "com.infotel.mobile.StartActivity");
    Assert.assertNull(capa.getCapability(MobileCapabilityType.FULL_RESET));
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) MutableCapabilities(org.openqa.selenium.MutableCapabilities) DriverConfig(com.seleniumtests.driver.DriverConfig) AndroidCapabilitiesFactory(com.seleniumtests.browserfactory.AndroidCapabilitiesFactory) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 33 with SeleniumTestsContext

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

the class TestAndroidCapabilitiesFactory method testCreateDefaultCapabilitiesWithNodeTagsInLocalMode.

/**
 * Check default behaviour when node tags are defined in local mode
 * tags are not transferred to driver
 */
@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithNodeTagsInLocalMode() {
    SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
    context.setBrowser(BrowserType.CHROME.toString());
    context.setNodeTags("foo,bar");
    context.setRunMode("local");
    context.setMobilePlatformVersion("8.0");
    context.setPlatform("android");
    context.setDeviceName("Samsung Galasy S8");
    context.setApp("");
    DriverConfig config = new DriverConfig(context);
    AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
    MutableCapabilities capa = capaFactory.createCapabilities();
    Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) MutableCapabilities(org.openqa.selenium.MutableCapabilities) DriverConfig(com.seleniumtests.driver.DriverConfig) AndroidCapabilitiesFactory(com.seleniumtests.browserfactory.AndroidCapabilitiesFactory) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 34 with SeleniumTestsContext

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

the class TestAndroidCapabilitiesFactory method testCreateDefaultAndroidBrowserCapabilities.

/**
 * Check default behaviour
 */
@Test(groups = { "ut" })
public void testCreateDefaultAndroidBrowserCapabilities() {
    SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
    context.setBrowser(BrowserType.BROWSER.toString());
    context.setMobilePlatformVersion("8.0");
    context.setPlatform("android");
    context.setDeviceName("Samsung Galasy S8");
    context.setApp("");
    DriverConfig config = new DriverConfig(context);
    AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
    MutableCapabilities capa = capaFactory.createCapabilities();
    Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), BrowserType.BROWSER.toString().toLowerCase());
    Assert.assertNull(capa.getCapability(ChromeOptions.CAPABILITY));
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.AUTOMATION_NAME), "Appium");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_NAME), "android");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_VERSION), "8.0");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.DEVICE_NAME), "Samsung Galasy S8");
    // from exampleConfigGenericParams.xml when tu.xml is executed, else, null
    Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_PACKAGE), "com.infotel.mobile");
    // from exampleConfigGenericParams.xml when tu.xml is executed, else, null
    Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_ACTIVITY), "com.infotel.mobile.StartActivity");
    Assert.assertNull(capa.getCapability(MobileCapabilityType.FULL_RESET));
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) MutableCapabilities(org.openqa.selenium.MutableCapabilities) DriverConfig(com.seleniumtests.driver.DriverConfig) AndroidCapabilitiesFactory(com.seleniumtests.browserfactory.AndroidCapabilitiesFactory) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 35 with SeleniumTestsContext

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

the class TestAndroidCapabilitiesFactory method testCreateCapabilitiesWithApplication.

/**
 * Check mobile test with app
 */
@Test(groups = { "ut" })
public void testCreateCapabilitiesWithApplication() {
    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("com.covea.mobileapp");
    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"), "com.covea.mobileapp");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.AUTOMATION_NAME), "Appium");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_NAME), "android");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_VERSION), "8.0");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.DEVICE_NAME), "Samsung Galasy S8");
    Assert.assertEquals(capa.getCapability(MobileCapabilityType.FULL_RESET), true);
    Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_PACKAGE), "appPackage");
    Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_ACTIVITY), "appActivity");
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) MutableCapabilities(org.openqa.selenium.MutableCapabilities) DriverConfig(com.seleniumtests.driver.DriverConfig) AndroidCapabilitiesFactory(com.seleniumtests.browserfactory.AndroidCapabilitiesFactory) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

SeleniumTestsContext (com.seleniumtests.core.SeleniumTestsContext)54 Test (org.testng.annotations.Test)44 GenericTest (com.seleniumtests.GenericTest)43 XmlTest (org.testng.xml.XmlTest)32 ITestResult (org.testng.ITestResult)12 AndroidCapabilitiesFactory (com.seleniumtests.browserfactory.AndroidCapabilitiesFactory)11 DriverConfig (com.seleniumtests.driver.DriverConfig)11 MutableCapabilities (org.openqa.selenium.MutableCapabilities)11 HashMap (java.util.HashMap)9 TestVariable (com.seleniumtests.core.TestVariable)7 ConnectorsTest (com.seleniumtests.ConnectorsTest)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 TestStep (com.seleniumtests.reporter.logger.TestStep)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Set (java.util.Set)4 ITestContext (org.testng.ITestContext)4 IOException (java.io.IOException)3 Map (java.util.Map)3