示例#1
0
        private int SilenceCreateNewPageSection(string pageSectionName, int pageID)
        {
            int pageSectionID = 0;

            if (pageSectionName == string.Empty)
            {
                return(pageSectionID);
            }

            var     sql                = new Sql();
            var     dataset            = new DataSetAutoTest();
            var     adapterPageSection = new GuiPageSectionTableAdapter();
            Boolean flag               = true;

            adapterPageSection.Fill(dataset.GuiPageSection);

            DataTableReader dtReader = dataset.GuiPageSection.CreateDataReader();

            while (dtReader.Read())
            {
                var pID   = dtReader.GetValue(1).ToString().Trim();
                var pName = dtReader.GetValue(2).ToString().Trim();
                if (pName == pageSectionName && Convert.ToInt32(pID) == pageID)
                {
                    flag = false;

                    // get existing page section ID
                    pageSectionID = Convert.ToInt32(dtReader.GetValue(0).ToString().Trim());
                    break;
                }
            }
            dtReader.Close();

            if (!flag)
            {
                return(pageSectionID);
            }
            // create new page section
            adapterPageSection.Insert(pageID, pageSectionName);

            // Get new Page Section's ID
            adapterPageSection.Fill(dataset.GuiPageSection);

            dtReader = dataset.GuiPageSection.CreateDataReader();
            while (dtReader.Read())
            {
                var pID   = dtReader.GetValue(1).ToString().Trim();
                var pName = dtReader.GetValue(2).ToString().Trim();

                if (pName == pageSectionName && Convert.ToInt32(pID) == pageID)
                {
                    pageSectionID = Convert.ToInt32(dtReader.GetValue(0).ToString().Trim());
                    break;
                }
            }
            dtReader.Close();
            return(pageSectionID);
        }
示例#2
0
        internal bool ExecuteOneTest(string testId, string inputDataRow, RemoteWebDriver driver, ref Dictionary <string, int> testStatus)
        {
            try
            {
                if (testId == string.Empty)
                {
                    MessageBox.Show("Select test first", "Applenium");
                    return(false);
                }
                if (testStatus.ContainsKey("TotalTests"))
                {
                    testStatus["TotalTests"] = testStatus["TotalTests"] + 1;
                }
                else
                {
                    testStatus.Add("TotalTests", 1);
                }

                var       sql                  = new Sql();
                DataTable dt                   = sql.GetDataTable(Constants.StrTestStepsToSelenium, testId);
                bool      testresult           = true;
                bool      recursivetestresult  = true;
                var       adapterGuiproject    = new GuiProjectPageTableAdapter();
                var       adapterTest          = new TestTableAdapter();
                var       adapteGuiPageSection = new GuiPageSectionTableAdapter();
                _testname = adapterTest.GetTestName(Convert.ToInt32(testId));

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


                LogObject logObject = new LogObject();



                logObject.Description = "*-------------------------------------------------------------------------------------------------------------\n" + "\t\t\t\t\t\t\t\t\t\t" + _testname + " Test Started\n-------------------------------------------------------------------------------------------------------------\n";
                logObject.StatusTag   = Constants.INFO;
                logger.Print(logObject);



                LogObject loggg = new LogObject();
                loggg.StepName     = _stepname;
                loggg.ExecutionID  = _runExecutionId;
                loggg.TestStatus   = Constants.PROGRESS_STARTED;
                loggg.TestName     = _testname;
                loggg.Description  = Constants.LogTestName + "=" + Constants.PROGRESS_STARTED;
                loggg.ScnearioName = _scenarioname;
                loggg.ProjectName  = _projectName;
                loggg.BatchName    = _batchname;
                loggg.Parameter1   = inputDataRow;
                loggg.StatusTag    = Constants.DONE;
                loggg.Exception    = null;
                logger.Print(loggg);



                var    jp = new JsonParser();
                string skipTestOnStepFail = Constants.MemoryConf["SkipTestOnStepFail"];


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

                if (inputDataRow != null)
                {
                    if (inputDataRow.IndexOf("rand", 0, StringComparison.Ordinal) >= 0)
                    {
                        if (inputDataRow.IndexOf("-", 0, StringComparison.Ordinal) >= 0)
                        {
                            string[] rows = inputDataRow.Split('-', '(', ')');
                            //get rundom number

                            Random random    = new Random();
                            int    rownumber = random.Next(Convert.ToInt32(rows[1]), Convert.ToInt32(rows[2]));

                            testresult = ExecuteOneTest(testId, rownumber.ToString(), driver,
                                                        ref testStatus);
                            if (testresult == false)
                            {
                                recursivetestresult = false;
                            }

                            return(recursivetestresult);
                        }
                    }

                    if (inputDataRow.IndexOf("-", 0, StringComparison.Ordinal) >= 0)
                    {
                        string[] rows = inputDataRow.Split('-');
                        for (int i = Convert.ToInt32(rows[0].ToString(CultureInfo.InvariantCulture));
                             i <= Convert.ToInt32(rows[1].ToString(CultureInfo.InvariantCulture));
                             i++)
                        {
                            testresult = ExecuteOneTest(testId, i.ToString(CultureInfo.InvariantCulture), driver, ref testStatus);
                            if (testresult == false)
                            {
                                recursivetestresult = false;
                            }
                        }
                        return(recursivetestresult);
                    }

                    if (inputDataRow.IndexOf(",", 0, StringComparison.Ordinal) >= 0)
                    {
                        string[] rows = inputDataRow.Split(',');
                        foreach (string key in rows)
                        {
                            testresult = ExecuteOneTest(testId, key, driver, ref testStatus);
                            if (testresult == false)
                            {
                                recursivetestresult = false;
                            }
                        }

                        return(recursivetestresult);
                    }
                    foreach (DataRow testrow in dt.Rows)
                    {
                        testrow["InputDataRow"] = inputDataRow;
                    }
                }
                foreach (DataRow row in dt.Rows)
                {
                    if (myInstance.StopExecution)
                    {
                        testresult = false;
                        break;
                    }
                    bool stepresult = ExecuteStep(row, driver);
                    if (stepresult == false)
                    {
                        testresult = false;
                        if (skipTestOnStepFail == "yes")
                        {
                            LogObject logObject2 = new LogObject();

                            logObject2.Description = "Previous Step is Failed => TestStatus=Skiped moving to next test";
                            logObject2.StatusTag   = Constants.ERROR;
                            logObject2.ExecutionID = _runExecutionId;
                            logObject2.Exception   = null;
                            logger.Print(logObject2);

                            break;
                        }
                    }
                }
                adapterTest.GetTestName(Convert.ToInt32(testId));
                int projectPageSectionId = Convert.ToInt32(adapterTest.GetPageSectionID(Convert.ToInt32(Convert.ToInt32(testId))));
                _projectPageId = Convert.ToInt32(adapteGuiPageSection.GetGuiPageID(projectPageSectionId));
                _projectId     = Convert.ToInt32(adapterGuiproject.GetProjectID(_projectPageId));

                LogObject logObject3 = new LogObject();
                if (testresult)
                {
                    //description = string.Format("{0}={1}", Constants.LogTestStatus, "Passed");
                    //status = Constants.Passed;


                    logObject3.TestStatus = Constants.PROGRESS_PASSED;
                    logObject3.StatusTag  = Constants.PASSED;


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

                else
                {
                    logObject3.TestStatus  = Constants.PROGRESS_FAILED;
                    logObject3.Description = _testname + " has failed";
                    logObject3.StatusTag   = Constants.FAILED;



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

                logObject3.Parameter1    = "";
                logObject3.Parameter2    = "";
                logObject3.Snapshot      = ss;
                logObject3.BatchID       = _batchId;
                logObject3.ScenarioID    = _flowId;
                logObject3.TestID        = Convert.ToInt32(testId);
                logObject3.TestName      = _testname;
                logObject3.ScnearioName  = _scenarioname;
                logObject3.BatchName     = _batchname;
                logObject3.StepID        = -1;
                logObject3.ExecutionID   = _runExecutionId;
                logObject3.ProjectPageID = _projectPageId;
                logObject3.ProjectName   = _projectName;
                logObject3.ProjectID     = _projectId;
                logger.Print(logObject3);


                //AppleniumLogger.LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0, description + " with DataRow=" + inputDataRow, status, "0", _projectId, _projectPageId);
                return(testresult);
            }
            catch (Exception exception)
            {
                LogObject logObject4 = new LogObject();
                logObject4.Description = exception.Message;
                logObject4.CommandName = string.Empty;
                logObject4.StatusTag   = Constants.EXECPTION;
                logObject4.Exception   = exception;
                logger.Print(logObject4);

                //AppleniumLogger.LogResult(string.Empty,exception.Message, Constants.Error, exception);
                return(false);
            }
        }
示例#3
0
        internal bool ExecuteOneTest(string testId, string inputDataRow, RemoteWebDriver driver, ref Dictionary <string, int> testStatus)
        {
            try
            {
                if (testId == string.Empty)
                {
                    MessageBox.Show("Select test first", "Applenium");
                    return(false);
                }
                if (testStatus.ContainsKey("TotalTests"))
                {
                    testStatus["TotalTests"] = testStatus["TotalTests"] + 1;
                }
                else
                {
                    testStatus.Add("TotalTests", 1);
                }

                var sql = new Sql();

                DataTable dt                   = sql.GetDataTable(Constants.StrTestStepsToSelenium, testId);
                bool      testresult           = true;
                bool      recursivetestresult  = true;
                var       adapterGuiproject    = new GuiProjectPageTableAdapter();
                var       adapterTest          = new TestTableAdapter();
                var       adapteGuiPageSection = new GuiPageSectionTableAdapter();
                string    testname             = adapterTest.GetTestName(Convert.ToInt32(testId));

                if (guiInstance != null && isBatchRun == false)
                {
                    guiInstance.UpdateProgressLabel(testname);
                }

                LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0,
                          "TestStatus=Started with DataRow=" + inputDataRow, Constants.Done, "0", _projectId,
                          _projectPageId);
                var    jp = new JsonParser();
                string skipTestOnStepFail = jp.ReadJson("SkipTestOnStepFail");


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

                if (inputDataRow != null)
                {
                    if (inputDataRow.IndexOf("-", 0, StringComparison.Ordinal) >= 0)
                    {
                        string[] rows = inputDataRow.Split('-');
                        for (int i = Convert.ToInt32(rows[0].ToString(CultureInfo.InvariantCulture));
                             i <= Convert.ToInt32(rows[1].ToString(CultureInfo.InvariantCulture));
                             i++)
                        {
                            testresult = ExecuteOneTest(testId, i.ToString(CultureInfo.InvariantCulture), driver, ref testStatus);
                            if (testresult == false)
                            {
                                recursivetestresult = false;
                            }
                        }
                        return(recursivetestresult);
                    }

                    if (inputDataRow.IndexOf(",", 0, StringComparison.Ordinal) >= 0)
                    {
                        string[] rows = inputDataRow.Split(',');
                        foreach (string key in rows)
                        {
                            testresult = ExecuteOneTest(testId, key, driver, ref testStatus);
                            if (testresult == false)
                            {
                                recursivetestresult = false;
                            }
                        }

                        return(recursivetestresult);
                    }
                    foreach (DataRow testrow in dt.Rows)
                    {
                        testrow["InputDataRow"] = inputDataRow;
                    }
                }
                foreach (DataRow row in dt.Rows)
                {
                    if (myInstance.StopExecution)
                    {
                        testresult = false;
                        break;
                    }
                    bool stepresult = ExecuteStep(row, driver);
                    if (stepresult == false)
                    {
                        testresult = false;
                        if (skipTestOnStepFail == "yes")
                        {
                            LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0,
                                      " Previous Step is Failed => TestStatus=Skiped moving to next test", Constants.Error, "0", _projectId, _projectPageId);
                            break;
                        }
                    }
                }
                adapterTest.GetTestName(Convert.ToInt32(testId));
                int projectPageSectionId = Convert.ToInt32(adapterTest.GetProjectPageID(Convert.ToInt32(Convert.ToInt32(testId))));
                _projectPageId = Convert.ToInt32(adapteGuiPageSection.GetGuiPageID(projectPageSectionId));
                _projectId     = Convert.ToInt32(adapterGuiproject.GetProjectID(_projectPageId));
                string description;
                int    status;
                if (testresult)
                {
                    description = string.Format("{0}={1}", Constants.LogTestStatus, "Passed");
                    status      = Constants.Passed;
                    if (testStatus.ContainsKey("PassedTests"))
                    {
                        testStatus["PassedTests"] = testStatus["PassedTests"] + 1;
                    }
                    else
                    {
                        testStatus.Add("PassedTests", 1);
                    }

                    //LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0,testname + " Test Passed  with data row : " + inputDataRow, Constants.Passed, "0",_projectId,_projectPageId);
                }

                else
                {
                    //LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0,testname + " Test Failed  with data row : " + inputDataRow, Constants.Failed, "0",_projectId,_projectPageId);
                    description = string.Format("{0}={1}", Constants.LogTestStatus, "Failed");
                    status      = Constants.Failed;
                    if (testStatus.ContainsKey("FailedTests"))
                    {
                        testStatus["FailedTests"] = testStatus["FailedTests"] + 1;
                    }
                    else
                    {
                        testStatus.Add("FailedTests", 1);
                    }
                }
                LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0, description + " with DataRow=" + inputDataRow, status, "0", _projectId, _projectPageId);
                return(testresult);
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(false);
            }
        }