Example #1
0
        public void SetupTest()
        {
            if (inputDriverName != string.Empty)
            {
                driver = TestDataParameter.GetDriverNameFromXML(inputDriverName, TestContext.CurrentContext.Test.Name);

                if (driver == null)
                {
                    Assert.Ignore("Fixture doesn't exist in the list");
                }
            }
            else
            {
                Assert.Ignore("Parameters are not provided for Fixture");
            }
        }
Example #2
0
        /// <summary>
        /// Include Test Case
        /// </summary>
        /// <param name="testName"></param>
        /// <returns></returns>
        public static bool IncludeTestCase(string testName)
        {
            XDocument xmlTestCaseData = TestDataParameter.ReadMobileTestCaseDatafromXML();
            var       testCases       = from testCase in xmlTestCaseData.Descendants("TestCases").Descendants("add")
                                        select new { Include = testCase.Attribute("Include").Value, Name = testCase.Attribute("name").Value };

            testCases = testCases.Where(x => x.Include == "1" && x.Name == testName);
            if (testCases.Count() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public void SetupTest()
        {
            totalScriptsCount++;
            countDataSet++;
            ignoredScriptsFlag = true;
            if (inputDriverName != string.Empty)
            {
                driver = TestDataParameter.GetDriverNameFromXML(inputDriverName, TestContext.CurrentContext.Test.Name);

                if (driver == null)
                {
                    Assert.Ignore("Fixture doesn't exist in the list");
                }
            }
            else
            {
                Assert.Ignore("Parameters are not provided for Fixture");
            }

            includeTestCase = TestDataParameter.IncludeTestCase(TestContext.CurrentContext.Test.Name.Substring(0, TestContext.CurrentContext.Test.Name.IndexOf("(")));
        }
Example #4
0
        /// <summary>
        ///  Get Driver Name From XML
        /// </summary>
        /// <param name="name"></param>
        /// <param name="testCaseName"></param>
        /// <returns></returns>
        public static IWebDriver GetDriverNameFromXML(string name, string testCaseName)
        {
            IWebDriver driver;
            string     selectedBrowser = string.Empty;
            //Read driver from XML file

            XDocument xmlTestCaseData = TestDataParameter.ReadMobileTestCaseDatafromXML();
            var       browsers        = from browser in xmlTestCaseData.Descendants("TestFixtures").Descendants("add")
                                        select new { Include = browser.Attribute("Include").Value, Name = browser.Attribute("name").Value };

            browsers = browsers.Where(x => x.Include == "1" && x.Name == name.Trim());
            if (browsers.Count() > 0)
            {
                selectedBrowser = browsers.FirstOrDefault().Name;                //read from data xml
            }
            else
            {
                return(null);
            }


            //selectedBrowser = name;
            switch (selectedBrowser)
            {
            //Browsers

            case Constants.BROWSER_CHROMELOCAL:
                driver = SeleniumDriverObject.GetChromeDriver();
                break;

            case Constants.BROWSER_IELOCAL:
                driver = SeleniumDriverObject.GetInternetExplorerDriver();
                break;

            case Constants.BROWSER_FIREFOXLOCAL:
                driver = SeleniumDriverObject.GetFireFoxDriver();
                break;

            case Constants.BROWSER_IE_11:
                driver = SeleniumDriverObject.Get_Browserstack_IE11(testCaseName, name);
                break;

            case Constants.BROWSER_CHROME:
                driver = SeleniumDriverObject.Get_Browserstack_Chrome(testCaseName, name);
                break;

            case Constants.BROWSER_FIREFOX:
                driver = SeleniumDriverObject.Get_Browserstack_Firefox(testCaseName, name);
                break;

            case Constants.BROWSER_SAFARI:
                driver = SeleniumDriverObject.Get_Browserstack_Safari(testCaseName, name);
                break;

            //Iphone and Ipad Portrait
            case Constants.BROWSERSTACK_IPHONE6S_PORTRAIT:
                driver = SeleniumDriverObject.GetIphone6SBrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_IPADMINI4_PORTRAIT:
                driver = SeleniumDriverObject.GetIpadMini4BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_IPHONE6SPLUS_PORTRAIT:
                driver = SeleniumDriverObject.GetIphone6PlusBrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_IPADAIR_PORTRAIT:
                driver = SeleniumDriverObject.GetIpadAirBrowserStackDriver(testCaseName, name);
                break;

            // Iphone and Ipad Landscape
            case Constants.BROWSERSTACK_IPHONE6S_LANDSCAPE:
                driver = SeleniumDriverObject.GetIphone6SBrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_IPADMINI4_LANDSCAPE:
                driver = SeleniumDriverObject.GetIpadMini4BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_IPHONE6SPLUS_LANDSCAPE:
                driver = SeleniumDriverObject.GetIphone6PlusBrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_IPADAIR_LANDSCAPE:
                driver = SeleniumDriverObject.GetIpadAirBrowserStackDriver(testCaseName, name);
                break;

            //ANDROID Portrait
            case Constants.BROWSERSTACK_HTCONEM8_PORTRAIT:
                driver = SeleniumDriverObject.GetHTCOneM8BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_SAMSUNGNOTE4_PORTRAIT:
                driver = SeleniumDriverObject.GetSamsungGalaxyNote4BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_SAMSUNGS7_PORTRAIT:
                driver = SeleniumDriverObject.GetSamsungGalaxyS7BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_GOOGLENEXUS9_PORTRAIT:
                driver = SeleniumDriverObject.GetGoogleNexus9BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_GOOGLEPIXEL_PORTRAIT:
                driver = SeleniumDriverObject.GetGooglePixelBrowserStackDriver(testCaseName, name);
                break;

            //ANDROID LANDSCAPE
            case Constants.BROWSERSTACK_HTCONEM8_LANDSCAPE:
                driver = SeleniumDriverObject.GetHTCOneM8BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_SAMSUNGS7_Landscape:
                driver = SeleniumDriverObject.GetSamsungGalaxyS7BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_SAMSUNGNOTE4_Landscape:
                driver = SeleniumDriverObject.GetSamsungGalaxyNote4BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_GOOGLENEXUS9_LANDSCAPE:
                driver = SeleniumDriverObject.GetGoogleNexus9BrowserStackDriver(testCaseName, name);
                break;

            case Constants.BROWSERSTACK_GOOGLEPIXEL_LANDSCAPE:
                driver = SeleniumDriverObject.GetGooglePixelBrowserStackDriver(testCaseName, name);
                break;

            default:
                driver = null;
                break;
            }
            return(driver);
        }