//[BeforeScenario("Selenium")]
        public static void BeforeWebScenarioSelenium(string browserTypeFromConsole, string urlFromConsole, string authUser, string authPass, string authType)
        {
            var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt");

            DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "tfsReportStatus", "");
            var brType   = browserTypeFromConsole;
            var urlToRun = urlFromConsole;

            switch (brType.ToLower())
            {
            case "ie":
                Driver.StartBrowser(BrowserTypes.InternetExplorer);
                Driver.Browser.Manage().Window.Maximize();
                UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser);
                browserType = "IE";
                break;

            case "chrome":
                Driver.StartBrowser(BrowserTypes.Chrome);
                Driver.Browser.Manage().Window.Maximize();
                UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser);
                browserType = "Chrome";
                break;

            default:
                break;
            }

            //Driver.Browser.Navigate().GoToUrl(urlToRun);

            //if(authUser !=null & authPass !=null & authType != null)
            //{
            //    Authenticate(authUser, authPass, authType);
            //}
        }
Пример #2
0
        public void ErrorMessageTFS(string errorMessage, string fatalORFailed)
        {
            Console.Write(fatalORFailed.ToUpper() + ": " + errorMessage + System.Environment.NewLine + "Screenshot: " + testName + dateFormatFileNameStr + ".png" + System.Environment.NewLine + "StackTrace:" + System.Environment.NewLine + ReturnString.FormatingStackTrace(Environment.StackTrace));
            var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt");

            DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "tfsReportStatus", "fail");
        }
        //[BeforeTestRun]
        public static void BeforeTestRun(string browserTypeFromConsole, string[] reports)
        {
            reportTypes = reports;
            var brType = browserTypeFromConsole;

            DateTime thisDay    = DateTime.Now;
            var      dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt");

            DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "Suffix", thisDay.ToString("yyyy.MM.dd HH:mm:ss", CultureInfo.InvariantCulture));
            string[] tokens     = thisDay.ToString("yyyy.MM.dd HH:mm:ss", CultureInfo.InvariantCulture).Split(':');
            string   pathString = System.IO.Path.Combine(ReturnPath.ProjectFolderPath() + "../TestResults/" + dictionary["projectName"] + "/", brType + "_TestReport-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec");

            System.IO.Directory.CreateDirectory(pathString);
            DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "ReportPath", pathString);

            if (StringOperations.ReturnString.StringIsValueOfArray(reports, "extentX"))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(ReturnPath.ProjectFolderPath() + "ExtentReport/ExtentXReportConf.xml");
                XmlNode confNode = doc.SelectSingleNode("/configuration");
                confNode.FirstChild.FirstChild.Value = dictionary["projectName"] + "-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec-" + brType;//FeatureContext.Current.FeatureInfo.Title;
                doc.Save(ReturnPath.ProjectFolderPath() + "ExtentReport/ExtentXReportConf.xml");
                extentX = new ExtentXReporter();
                extentX.LoadConfig(ReturnPath.ProjectFolderPath() + "ExtentReport/ExtentXReportConf.xml");

                if (StringOperations.ReturnString.StringIsValueOfArray(reports, "extent"))
                {
                    extentHTML = new ExtentHtmlReporter(pathString + "/TestReport-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec-" + brType + ".html");
                    extent     = new ExtentReports();
                    extent.AttachReporter(extentHTML, extentX);
                }
                else
                {
                    extent.AttachReporter(extentX);
                }
            }
            else
            {
                if (StringOperations.ReturnString.StringIsValueOfArray(reports, "extent"))
                {
                    extentHTML = new ExtentHtmlReporter(pathString + "/TestReport-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec-" + brType + ".html");
                    extent     = new ExtentReports();
                    extent.AttachReporter(extentHTML);
                }
            }
        }