コード例 #1
0
        public void ExecuteChecks(List <Check> checks)
        {
            bool allSuccessfull = true;

            string[,] paramList    = CreateParamList();
            string[,] xmlParamList = CreateXmlParamList(filePath);

            foreach (Check check in checks)
            {
                nav = fc.XpathNavigator(filePath);
                ReplacePlaceHolders(filePath, paramList);
                ReplacePlaceHolders(filePath, xmlParamList);
                string[,] stepList = null;
                if (check.Value != null && check.Value.Contains("[ActiveObject"))
                {
                    //PropertyInfo pi = typeof(Identity).GetProperty(step.Name);
                    //stepList = new string[,]{ { "$(Step.Name)", step.Name.ToLower() , "string" }, { "$(Step.Value)", pi.GetValue(person).ToString(), "string"} };
                    stepList = new string[, ] {
                        { "$(Step.Name)", check.Name, "string" }, { "$(Step.Value)", check.Value, "string" }
                    };
                }
                else
                {
                    stepList = new string[, ] {
                        { "$(Step.Name)", check.Name, "string" }, { "$(Step.Value)", check.Value, "string" }
                    };
                }
                ReplacePlaceHolders(filePath, stepList, check);

                check.Status = ExecuteCheck(driver, filePath, check.Name);

                if (check.Status != CheckStatus.Completed)
                {
                    allSuccessfull = false;
                }
            }

            ChecksExecuted(this, allSuccessfull);

            if (allSuccessfull)
            {
                AllChecksSuccessfull(this, new EventArgs());
            }
        }
コード例 #2
0
        private void GenerateFromFile()
        {
            string filePath = TextBoxFilePath.Text;

            BL.FunctionClass  fc       = new BL.FunctionClass();
            XPathNavigator    nav      = fc.XpathNavigator(filePath);
            XPathExpression   expr     = nav.Compile("//cases/case");
            XPathNodeIterator iterator = nav.Select(expr);

            testCases.Clear();
            while (iterator.MoveNext())
            {
                Case c = new Case
                {
                    name       = iterator.Current.SelectSingleNode("@name").Value,
                    selected   = false,
                    parameters = new List <param>(),
                    steps      = new List <TempStep>()
                };
                XPathExpression   paramExpr = iterator.Current.Compile("//case[@name='" + c.name + "']/param");
                XPathNodeIterator paramIt   = iterator.Current.Select(paramExpr);

                int k = 0;
                while (paramIt.MoveNext())
                {
                    param p = new param
                    {
                        name     = paramIt.Current.SelectSingleNode("@name").Value,
                        isActive = false,
                        type     = paramIt.Current.SelectSingleNode("@type").Value,
                        value    = paramIt.Current.SelectSingleNode("@value").Value
                    };
                    if (p.type == "xPath")
                    {
                        p.file = paramIt.Current.SelectSingleNode("@file").Value;
                    }
                    c.parameters.Add(p);
                    k++;
                }

                XPathExpression   stepExpr = iterator.Current.Compile("//case[@name='" + c.name + "']/step");
                XPathNodeIterator stepIt   = iterator.Current.Select(stepExpr);

                k = 0;
                while (stepIt.MoveNext())
                {
                    TempStep s = new TempStep()
                    {
                        isActive  = false,
                        extension = stepIt.Current.SelectSingleNode("@extension").Value,
                        value     = "",
                        element   = ""
                    };
                    s.name = s.extension;

                    if (s.extension != "Navigate")
                    {
                        s.element = stepIt.Current.SelectSingleNode("@element").Value;
                        s.action  = stepIt.Current.SelectSingleNode("@action").Value;

                        s.name += (" | " + s.element + " | " + s.action);
                        if (s.action == "SendKeys")
                        {
                            s.value = stepIt.Current.SelectSingleNode("@value").Value;
                        }
                    }
                    else
                    {
                        s.value = stepIt.Current.SelectSingleNode("@value").Value;
                        s.name += (" | " + s.value);
                    }

                    k++;
                    c.steps.Add(s);
                }
                testCases.Add(c);
            }
            showListboxItems();
        }
コード例 #3
0
 //!variables
 public StepExecutor(string filePath)
 {
     this.filePath = filePath;
     fc            = new FunctionClass();
     nav           = fc.XpathNavigator(filePath);
 }