Beispiel #1
0
        internal bool ExecuteOneScenario(string scenarioId, IWebDriver driver)
        {
            if (scenarioId == string.Empty)
            {
                MessageBox.Show("Select Scenario first", "Applenium");
                return(false);
            }

            _flowId = Convert.ToInt32(scenarioId);


            var       sql        = new Sql();
            DataTable dtScenario = sql.GetDataTable(Constants.StrScenarioTestsToSelenium, scenarioId);

            var adapterScenario = new ScenarioTableAdapter();

            _projectId = Convert.ToInt32(adapterScenario.GetProjectID(_flowId));
            string scenarioname = adapterScenario.GetScenarioName(_flowId);

            LogResult(_runExecutionId, _batchId, _flowId, 0, 0, scenarioname + " Scenario Started", Constants.Done, "0",
                      _projectId, 0);
            Singleton myInstance     = Singleton.Instance; // Will always be the same instance...
            bool      scenarioresult = true;

            foreach (DataRow row in dtScenario.Rows)
            {
                if (myInstance.StopExecution)
                {
                    scenarioresult = false;
                    break;
                }
                string testId = row["GuiTestID"].ToString();

                bool testresult = ExecuteOneTest(testId, row["InputDataRow"].ToString(), driver);
                if (testresult == false)
                {
                    scenarioresult = false;
                }
            }

            if (scenarioresult)
            {
                LogResult(_runExecutionId, _batchId, _flowId, 0, 0, scenarioname + " Scenario Passed", Constants.Passed,
                          "0", _projectId, 0);
            }
            else
            {
                LogResult(_runExecutionId, _batchId, _flowId, 0, 0, scenarioname + " Scenario Failed", Constants.Failed,
                          "0", _projectId, 0);
                //LogFailiure(_runExecutionID, flowID, scenario_name, 0, null, "Description in the test");
            }
            return(scenarioresult);
        }
Beispiel #2
0
        internal bool ExecuteOneScenario(string scenarioId, RemoteWebDriver driver)
        {
            //clean global configuration before ExecuteOneScenario
            var     jp  = new JsonParser();
            Boolean res = jp.AddConfigToMemory("");

            //init test status count
            var testStatus = new Dictionary <string, int>();

            if (testStatus.ContainsKey("PassedTests"))
            {
                testStatus["PassedTests"] = 0;
            }
            else
            {
                testStatus.Add("PassedTests", 0);
            }

            if (testStatus.ContainsKey("FailedTests"))
            {
                testStatus["FailedTests"] = 0;
            }
            else
            {
                testStatus.Add("FailedTests", 0);
            }
            if (testStatus.ContainsKey("TotalTests"))
            {
                testStatus["TotalTests"] = 0;
            }
            else
            {
                testStatus.Add("TotalTests", 0);
            }

            try
            {
                if (scenarioId == string.Empty)
                {
                    MessageBox.Show("Select Scenario first", "Applenium");
                    return(false);
                }

                _flowId = Convert.ToInt32(scenarioId);

                var       sql        = new Sql();
                DataTable dtScenario = sql.GetDataTable(Constants.StrScenarioTestsToSelenium, scenarioId);

                var adapterScenario = new ScenarioTableAdapter();
                _projectId    = Convert.ToInt32(adapterScenario.GetProjectID(_flowId));
                _scenarioname = adapterScenario.GetScenarioName(_flowId);
                string scenariodescription = adapterScenario.GetScenarioDescription(_flowId);

                if (guiInstance != null && isBatchRun == false)
                {
                    guiInstance.UpdateProgressLabel(_scenarioname, _testname, Constants.UpdateProgress_REGULAR);
                }


                LogObject logObject = new LogObject();
                logObject.Description = "-------------------------------------------------------------------------------------------------------------\n" + "\t\t\t\t\t\t\t\t\t\t" + _scenarioname + " Scenario Started\n-------------------------------------------------------------------------------------------------------------\n";
                logObject.StatusTag   = Constants.INFO;
                logger.Print(logObject);

                //                AppleniumLogger.LogResult(string.Empty,
                //"-------------------------------------------------------------------------------------------------------------\n" + "\t\t\t\t\t\t\t\t\t\t" + scenarioname + " Scenario Started\n-------------------------------------------------------------------------------------------------------------\n", Constants.Info, null);

                LogObject logObject2 = new LogObject();
                logObject2.ExecutionID    = _runExecutionId;
                logObject2.BatchID        = _batchId;
                logObject2.BatchName      = _batchname;
                logObject2.ProjectName    = _projectName;
                logObject2.ScenarioID     = _flowId;
                logObject2.ScenarioStatus = Constants.PROGRESS_STARTED;
                logObject2.StatusTag      = Constants.DONE;
                logObject2.Description    = Constants.LogScenarioStatus + "=" + Constants.PROGRESS_STARTED;
                logger.Print(logObject2);

                Singleton myInstance     = Singleton.Instance; // Will always be the same instance...
                bool      scenarioresult = true;

                LogObject result = new LogObject();
                foreach (DataRow row in dtScenario.Rows)
                {
                    // Check if we got a warning message, if we did skip all tests in the scenario
                    if (Applenium._4____Infrustructure.Utilities.skipSCN == true)
                    {
                        break;
                    }

                    if (myInstance.StopExecution)
                    {
                        scenarioresult = false;
                        break;
                    }
                    string testId = row["GuiTestID"].ToString();

                    bool testresult = ExecuteOneTest(testId, row["InputDataRow"].ToString(), driver, ref testStatus);
                    if (testresult == false)
                    {
                        scenarioresult = false;
                    }
                }
                string description;



                if (scenarioresult == true && Applenium._4____Infrustructure.Utilities.skipSCN == false)
                {
                    description = String.Format("{0}={1}", Constants.LogScenarioStatus, "Passed");

                    result.ScenarioStatus = Constants.PROGRESS_PASSED;
                    result.StatusTag      = Constants.PASSED;
                }
                else if (scenarioresult == false && Applenium._4____Infrustructure.Utilities.skipSCN == false)
                {
                    result.ScenarioStatus = Constants.PROGRESS_FAILED;
                    result.StatusTag      = Constants.FAILED;
                }

                else if (scenarioresult == true && Applenium._4____Infrustructure.Utilities.skipSCN == true)
                {
                    scenarioresult   = true;
                    result.StatusTag = Constants.DEBUG;
                }
                result.ExecutionID   = _runExecutionId;
                result.BatchID       = _batchId;
                result.BatchName     = _batchname;
                result.ScenarioID    = _flowId;
                result.ScnearioName  = _scenarioname;
                result.ProjectName   = _projectName;
                result.ProjectID     = _projectId;
                result.ProjectPageID = _projectPageId;
                result.BatchName     = _batchname;
                result.Description   = scenariodescription + " | PassedTest=" + testStatus["PassedTests"] + " | FailedTest=" + testStatus["FailedTests"] + " | TotalTest=" + testStatus["TotalTests"];
                result.ProjectID     = _projectId;
                result.Browser       = _browserName;
                logger.Print(result);

                Applenium._4____Infrustructure.Utilities.skipSCN = false;

                return(scenarioresult);
            }

            catch (Exception exception)
            {
                LogObject logObject3 = new LogObject();
                logObject3.Exception   = exception;
                logObject3.StatusTag   = Constants.ERROR;
                logObject3.Description = exception.Message;
                logger.Print(logObject3);
                return(false);
            }
        }
Beispiel #3
0
        internal bool ExecuteOneScenario(string scenarioId, RemoteWebDriver driver)
        {
            //init test status count
            var testStatus = new Dictionary <string, int>();

            if (testStatus.ContainsKey("PassedTests"))
            {
                testStatus["PassedTests"] = 0;
            }
            else
            {
                testStatus.Add("PassedTests", 0);
            }

            if (testStatus.ContainsKey("FailedTests"))
            {
                testStatus["FailedTests"] = 0;
            }
            else
            {
                testStatus.Add("FailedTests", 0);
            }
            if (testStatus.ContainsKey("TotalTests"))
            {
                testStatus["TotalTests"] = 0;
            }
            else
            {
                testStatus.Add("TotalTests", 0);
            }

            try
            {
                if (scenarioId == string.Empty)
                {
                    MessageBox.Show("Select Scenario first", "Applenium");
                    return(false);
                }

                _flowId = Convert.ToInt32(scenarioId);


                var       sql        = new Sql();
                DataTable dtScenario = sql.GetDataTable(Constants.StrScenarioTestsToSelenium, scenarioId);

                var adapterScenario = new ScenarioTableAdapter();
                _projectId = Convert.ToInt32(adapterScenario.GetProjectID(_flowId));
                string scenarioname = adapterScenario.GetScenarioName(_flowId);
                LogResult(_runExecutionId, _batchId, _flowId, 0, 0, String.Format("{0}={1}", Constants.LogScenarioStatus, "Started"), Constants.Done,
                          "0",
                          _projectId, _projectPageId);
                Singleton myInstance     = Singleton.Instance; // Will always be the same instance...
                bool      scenarioresult = true;
                foreach (DataRow row in dtScenario.Rows)
                {
                    if (myInstance.StopExecution)
                    {
                        scenarioresult = false;
                        break;
                    }
                    string testId = row["GuiTestID"].ToString();

                    bool testresult = ExecuteOneTest(testId, row["InputDataRow"].ToString(), driver, ref testStatus);
                    if (testresult == false)
                    {
                        scenarioresult = false;
                    }
                }
                string description;
                int    status;
                if (scenarioresult)
                {
                    description = String.Format("{0}={1}", Constants.LogScenarioStatus, "Passed");
                    status      = Constants.Passed;
                    //     LogResult(_runExecutionId, _batchId, _flowId, 0, 0, scenarioname + " Scenario Passed",Constants.Passed,"0", _projectId, 0);
                }
                else
                {
                    //LogResult(_runExecutionId, _batchId, _flowId, 0, 0, scenarioname + " Scenario Failed",Constants.Failed,"0", _projectId, 0);
                    description = String.Format("{0}={1}", Constants.LogScenarioStatus, "Failed");
                    status      = Constants.Failed;
                }
                LogResult(_runExecutionId, _batchId, _flowId, 0, 0, description + " : PassedTest=" + testStatus["PassedTests"] + " FailedTest=" + testStatus["FailedTests"] + " TotalTest=" + testStatus["TotalTests"], status, "0", _projectId, 0);
                return(scenarioresult);
            }

            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(false);
            }
        }