Search in sources :

Example 41 with SeleniumTestsContext

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

the class TestConfigReader method mergeIniAndXmlConfiguration.

/**
 * Check that parameters in XML (which are not identified as a seleniumRobot option) are also put in testConfiguration
 * @param testNGCtx
 * @param xmlTest
 */
@Test(groups = { "ut context" })
public void mergeIniAndXmlConfiguration(final ITestContext testNGCtx, final XmlTest xmlTest) {
    initThreadContext(testNGCtx);
    SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
    Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("variable1").getValue(), "value1", "Value has not been get from xml file");
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) XmlTest(org.testng.xml.XmlTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 42 with SeleniumTestsContext

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

the class TestConfigReader method testLoadMultipleFiles.

/**
 * Last file variables take precedence
 * @param testNGCtx
 */
@Test(groups = { "ut" })
public void testLoadMultipleFiles(final ITestContext testNGCtx) {
    try {
        System.setProperty(SeleniumTestsContext.LOAD_INI, "envSpecific.ini,spec/envSpecific2.ini");
        initThreadContext(testNGCtx);
        SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
        // check variable overwriting is also OK from last loaded files
        Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key10").getValue(), "value100");
        // check values are overwritten by first loaded ini file
        Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key2").getValue(), "value20");
        // check that if value is not present in additional file, it's taken from env.ini/config.ini
        Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("proxyType").getValue(), "direct");
    } finally {
        System.clearProperty(SeleniumTestsContext.LOAD_INI);
    }
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) XmlTest(org.testng.xml.XmlTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 43 with SeleniumTestsContext

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

the class TestConfigReader method testVariableOverwriteByEnvironment.

/**
 * Check that through context, configuration is correctly read
 * @param testNGCtx
 */
@Test(groups = { "ut" })
public void testVariableOverwriteByEnvironment(final ITestContext testNGCtx) {
    initThreadContext(testNGCtx);
    SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
    // check value from a loaded additional ini file is present in configuration
    Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key1").getValue(), "value4");
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) XmlTest(org.testng.xml.XmlTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 44 with SeleniumTestsContext

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

the class TestConfigReader method testLoadFileSubFolder.

/**
 * Check we can read files in sub folders of config
 * @param testNGCtx
 */
@Test(groups = { "ut" })
public void testLoadFileSubFolder(final ITestContext testNGCtx) {
    try {
        System.setProperty(SeleniumTestsContext.LOAD_INI, "spec/envSpecific2.ini");
        initThreadContext(testNGCtx);
        SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
        // check variable overwriting is also OK on loaded files
        Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key10").getValue(), "value100");
    } finally {
        System.clearProperty(SeleniumTestsContext.LOAD_INI);
    }
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) XmlTest(org.testng.xml.XmlTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 45 with SeleniumTestsContext

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

the class TestSeleniumTestContext method testProxyPresetExcludeCaptureNetworkWithAutoDetect.

@Test(groups = "ut context", expectedExceptions = ConfigurationException.class)
public void testProxyPresetExcludeCaptureNetworkWithAutoDetect(final ITestContext testNGCtx, final XmlTest xmlTest) {
    SeleniumTestsContextManager.generateApplicationPath(testNGCtx.getCurrentXmlTest().getSuite());
    SeleniumTestsContext seleniumContext = new SeleniumTestsContext();
    seleniumContext.setCaptureNetwork(true);
    seleniumContext.setWebProxyType("AUTODETECT");
    seleniumContext.setConfiguration(new HashMap<>());
    seleniumContext.setTestConfiguration();
    seleniumContext.updateProxyConfig();
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) Test(org.testng.annotations.Test) XmlTest(org.testng.xml.XmlTest) 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