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();
        }
예제 #2
0
 //!variables
 public StepExecutor(string filePath)
 {
     this.filePath = filePath;
     fc            = new FunctionClass();
     nav           = fc.XpathNavigator(filePath);
 }