public bool SendKeys(XmlNode node, PageElementsManager pageElements, string sendText)
        {
            var elementName = node.Attributes["element"].Value;

            if (pageElements != null)
            {
                var pageElement = GetElementNode(elementName, pageElements);

                if (pageElement == null)
                {
                    return(false);
                }

                var waitTime = pageElement.Attributes["wait"] != null ? pageElement.Attributes["wait"].Value : "2000";

                var foundElement = GetWebElement(pageElement);

                if (foundElement != null)
                {
                    foundElement.SendKeys(sendText);
                }

                Thread.Sleep(Convert.ToInt32(waitTime));
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public void RunTests(string path = ".")
        {
            const string message = "WELCOME TO TESTMANAGER!";

            string[] files = new string[0];

            if (path.Equals("./"))
            {
                files = Directory.GetFiles(Environment.CurrentDirectory, "*_TestManager.xml");
            }
            else
            {
                files = Directory.GetFiles(path, "*_TestManager.xml");
            }

            foreach (var file in files)
            {
                logger.Log(message);
                Console.WriteLine(message);
                currentTestPage = Path.GetFileNameWithoutExtension(file).Replace("_TestManager", "");
                elementsManager = new PageElementsManager(currentTestPage);
                RunTestFile(file);
            }
        }
 private XmlNode GetElementNode(string elementName, PageElementsManager pageElements)
 {
     return(pageElements.GetElement(elementName));
 }
        public bool Assert(XmlNode node, PageElementsManager pageElements, string assertOperator, string value, out string error)
        {
            error = string.Empty;
            var elementName = node.Attributes["element"].Value;

            if (pageElements != null)
            {
                var pageElement = GetElementNode(elementName, pageElements);

                if (pageElement == null)
                {
                    error = $"Page Element {elementName} is null.";
                    return(false);
                }


                var foundElement = GetWebElement(pageElement);

                if (foundElement == null)
                {
                    error = $"Web Element {elementName} is null.";
                    return(false);
                }

                switch (assertOperator)
                {
                case "equal":
                case "equals":
                case "=":
                {
                    return(foundElement.Text == value);
                }

                case "contains":
                {
                    return(foundElement.Text.Contains(value));
                }

                case "startswith":
                {
                    return(foundElement.Text.StartsWith(value));
                }

                case "endswith":
                {
                    return(foundElement.Text.EndsWith(value));
                }

                case "greater":
                case "greaterthan":
                case ">":
                {
                    return(Convert.ToInt32(foundElement.Text) > Convert.ToInt32(value));
                }

                case "less":
                case "lessthan":
                case "<":
                {
                    return(Convert.ToInt32(foundElement.Text) < Convert.ToInt32(value));
                }

                case "notequal":
                case "!=":
                {
                    return(!foundElement.Text.Equals(value));
                }

                case "null":
                {
                    return(string.IsNullOrEmpty(value));
                }
                }

                return(true);
            }
            return(false);
        }