Ejemplo n.º 1
0
        public HtmlControl[] GetValidation()
        {
            var elements       = new List <HtmlControl>();
            var elementWrapper = new HtmlControl(mainpage);

            elementWrapper.SearchProperties.Add(HtmlControl.PropertyNames.Class, "validation-summary-errors");
            var list = new HtmlControl(elementWrapper);

            list.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "UL");
            list.SearchProperties.Add(HtmlControl.PropertyNames.TagInstance, "1");
            var kids = list.GetChildren().Count;

            for (var index = 1; index <= list.GetChildren().Count; index++)
            {
                var element = new HtmlCustom(list);
                element.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "LI");
                element.SearchProperties.Add(HtmlControl.PropertyNames.TagInstance, index.ToString());
                elements.Add(element);
            }
            return(elements.ToArray());
        }
Ejemplo n.º 2
0
        public HtmlControl[] GetWhatYouCanDoList()
        {
            var elements    = new List <HtmlControl>();
            var listelement = new HtmlControl(mainpage);

            listelement.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "OL");
            listelement.SearchProperties.Add(HtmlControl.PropertyNames.TagInstance, "2");
            for (var index = 1; index <= listelement.GetChildren().Count; index++)
            {
                var element = new HtmlCustom(listelement);
                element.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "LI");
                element.SearchProperties.Add(HtmlControl.PropertyNames.TagInstance, index.ToString());
                elements.Add(element);
            }
            return(elements.ToArray());
        }
        /// <summary>
        /// Gets children count of parent control
        /// </summary>
        /// <param name="viewName"></param>
        /// <param name="controlName"></param>
        /// <param name="waitTime"></param>
        /// <param name="dynamicVariable"></param>
        /// <returns></returns>
        public static string[] GetChildrenControlNames(string viewName, string controlName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "")
        {
            Logger.InsertLogLine("Get Childreh controls Name- Control: " + controlName + " in View : " + viewName);
            UITestControlCollection children = new UITestControlCollection();
            Control control = PopulateControl(viewName, controlName, dynamicVariable);
            if (control.ControlZone == "Native")
            {
                xamlControl = GetXamlControl(control, dynamicVariable, waitTime);
                xamlControl.WaitForControlExist(waitTime);
                children = xamlControl.GetChildren();
            }

            else if (control.ControlZone == "Web")
            {
                htmlControl = GetHtmlControl(control, dynamicVariable, waitTime);
                children = htmlControl.GetChildren();
            }
            else if (control.ControlZone == "DirectUI")
            {
                directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime);
                directUIControl.WaitForControlExist(waitTime);
                children = directUIControl.GetChildren();
            }

            string[] myList = new string[50];
            for (int i = 0; i < children.Count; i++)
            {
                myList[i] = children[i].Name;
            }
            return myList;
        }
        /// <summary>
        /// Gets children count of parent control
        /// </summary>
        /// <param name="viewName"></param>
        /// <param name="controlName"></param>
        /// <param name="waitTime"></param>
        /// <param name="dynamicVariable"></param>
        /// <returns></returns>
        public static int GetChildrenControlCount(string viewName, string controlName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "")
        {
            Logger.InsertLogLine("Get Childreh control count- Control: " + controlName + " in View : " + viewName);
            int ChildrenCount = 0;
            Control control = PopulateControl(viewName, controlName, dynamicVariable);
            if (control.ControlZone == "Native")
            {
                xamlControl = GetXamlControl(control, dynamicVariable, waitTime);
                xamlControl.WaitForControlExist(waitTime);
                ChildrenCount = xamlControl.GetChildren().Count;
            }

            else if (control.ControlZone == "Web")
            {
                htmlControl = GetHtmlControl(control, dynamicVariable, waitTime);
                ChildrenCount = htmlControl.GetChildren().Count;
            }
            else if (control.ControlZone == "DirectUI")
            {
                directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime);
                directUIControl.WaitForControlExist(waitTime);
                ChildrenCount = directUIControl.GetChildren().Count;
            }
            return ChildrenCount;
        }
        public static void ClickChildrensChildByNameAtFirstLevel(string viewName, string controlName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "", string ChildName = "")
        {
            Control control = PopulateControl(viewName, controlName, dynamicVariable);
            Logger.InsertLogLine("Get Childreh control count- Control: " + controlName + " in View : " + viewName);
            Logger.InsertLogLine("Click on children's child: " + ChildName + "in control: " + control.ControlName + " in View : " + viewName);
            UITestControlCollection children = new UITestControlCollection();
            if (control.ControlZone == "Native")
            {
                xamlControl = GetXamlControl(control, dynamicVariable, waitTime);
                xamlControl.WaitForControlExist(waitTime);
                children = xamlControl.GetChildren();
            }

            else if (control.ControlZone == "Web")
            {
                htmlControl = GetHtmlControl(control, dynamicVariable, waitTime);
                children = htmlControl.GetChildren();
            }
            else if (control.ControlZone == "DirectUI")
            {
                directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime);
                directUIControl.WaitForControlExist(waitTime);
                children = directUIControl.GetChildren();
            }

            for (int j = 0; j < children.Count; j++)
            {
                string chname = children[j].Name;

                if (children[j].Name.Contains(ChildName))
                {
                    Gesture.Tap(new Point(children[j].BoundingRectangle.X + children[j].BoundingRectangle.Width / 2, children[j].BoundingRectangle.Y + children[j].BoundingRectangle.Height / 2));
                }
            }
        }
        public static bool VerifyChildrensChildControlByName(string viewName, string controlName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "", string ChildName = "")
        {
            Logger.InsertLogLine("Get Childreh control count- Control: " + controlName + " in View : " + viewName);
            UITestControlCollection children = new UITestControlCollection();
            Control control = PopulateControl(viewName, controlName, dynamicVariable);
            if (control.ControlZone == "Native")
            {
                xamlControl = GetXamlControl(control, dynamicVariable, waitTime);
                xamlControl.WaitForControlExist(waitTime);
                children = xamlControl.GetChildren();
            }

            else if (control.ControlZone == "Web")
            {
                htmlControl = GetHtmlControl(control, dynamicVariable, waitTime);
                children = htmlControl.GetChildren();
            }
            else if (control.ControlZone == "DirectUI")
            {
                directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime);
                directUIControl.WaitForControlExist(waitTime);
                children = directUIControl.GetChildren();
            }

            for (int i = 0; i < children.Count; i++)
            {
                string chname = children[i].Name;

                UITestControlCollection children1 = new UITestControlCollection();

                children1 = children[i].GetChildren();

                for (int j = 0; j < children.Count; j++)
                {
                    string chchname = children1[j].Name;
                    if (children1[j].Name.Contains(ChildName))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
        public static bool VerifyChildByName(string viewName, string controlName, string childName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "")
        {
            bool exists = false;
            UITestControlCollection children = null;
            UITestControl child = null;
            Control control = PopulateControl(viewName, controlName, dynamicVariable);
            if (control.ControlZone == "Native")
            {
                xamlControl = GetXamlControl(control, dynamicVariable, waitTime);
                xamlControl.WaitForControlExist(waitTime);
                children = xamlControl.GetChildren();
            }

            else if (control.ControlZone == "Web")
            {
                htmlControl = GetHtmlControl(control, dynamicVariable, waitTime);
                children = htmlControl.GetChildren();
            }
            else if (control.ControlZone == "DirectUI")
            {
                directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime);
                directUIControl.WaitForControlExist(waitTime);
                children = directUIControl.GetChildren();
            }
            for (int i = 0; i < children.Count; i++)
            {
                child = children[i];
                string name = child.GetProperty("Name").ToString();
                if (name.Contains(childName))
                {
                    exists = true;
                }
            }
            return exists;
        }
        public static void ClickAndVerifyColorOfChildrenByInstance(string viewName, string controlName, Color samplecolor, out bool ColorCompareResult, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "", int ChildInstance = 1)
        {
            ColorCompareResult = false;
            Control control = PopulateControl(viewName, controlName, dynamicVariable);
            Logger.InsertLogLine("Get Childreh control count- Control: " + controlName + " in View : " + viewName);
            Logger.InsertLogLine("Click on children's child: " + ChildInstance.ToString() + "in control: " + control.ControlName + " in View : " + viewName);
            UITestControlCollection children = new UITestControlCollection();
            if (control.ControlZone == "Native")
            {
                xamlControl = GetXamlControl(control, dynamicVariable, waitTime);
                xamlControl.WaitForControlExist(waitTime);
                children = xamlControl.GetChildren();
            }

            else if (control.ControlZone == "Web")
            {
                htmlControl = GetHtmlControl(control, dynamicVariable, waitTime);
                children = htmlControl.GetChildren();
            }
            else if (control.ControlZone == "DirectUI")
            {
                directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime);
                directUIControl.WaitForControlExist(waitTime);
                children = directUIControl.GetChildren();
            }

            for (int j = 0; j < children.Count; j++)
            {
                if (j == ChildInstance - 1)
                {
                    UITestControl uicontrol = children[j];
                    ColorCompareResult = CompareControlImageColor(uicontrol, samplecolor);
                    Gesture.Tap(new Point(children[j].BoundingRectangle.X + children[j].BoundingRectangle.Width / 2, children[j].BoundingRectangle.Y + children[j].BoundingRectangle.Height / 2));
                }
            }
        }