Example #1
0
 public string[] GetContent()
 {
     if (this.GetHeaderListOfListView() == null)
     {
         UITestControlCollection items = this.Items;
         if (items != null)
         {
             return(items.GetNamesOfControls());
         }
     }
     else
     {
         var list = new List <string>();
         UITestControlCollection controls2 = this.Items;
         if (controls2 != null)
         {
             foreach (Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinListItem item in controls2)
             {
                 list.AddRange(item.GetColumnValues());
             }
             return(list.ToArray());
         }
     }
     return(null);
 }
Example #2
0
        public UITestControl GetStepType(int stepIndex)
        {
            UITestControlCollection uiTestControlCollection = GetOutputWindow();

            Assert.IsTrue(uiTestControlCollection.Count > 0);
            return(uiTestControlCollection[stepIndex]);
        }
        public string GetActiveTabName()
        {
            var idx = _tabManager.SelectedIndex;

            if (idx == -1)
            {
                Playback.Wait(2500);
                idx = _tabManager.SelectedIndex;
            }


            UITestControl           tab         = _tabManager.Tabs[idx];
            UITestControlCollection tabChildren = tab.GetChildren();
            string selectedTabName = string.Empty;

            foreach (var tabChild in tabChildren)
            {
                if (tabChild.ClassName == "Uia.TextBlock")
                {
                    selectedTabName = tabChild.FriendlyName;
                    break;
                }
            }
            //string selectedTabName = theTabManager.Tabs[theTabManager.SelectedIndex].FriendlyName;
            return(selectedTabName);
        }
        public UITestControl getControl(string tabName, string buttonText)
        {
            UITestControl returnControl   = new UITestControl();
            WpfTabList    uIRibbonTabList = this.UIBusinessDesignStudioWindow.UIRibbonTabList;

            //int tabCount = uIRibbonTabList.Tabs.Count;
            foreach (WpfTabPage buttonList in uIRibbonTabList.Tabs)
            {
                if (buttonList.FriendlyName == tabName)
                {
                    UITestControlCollection buttonListChildren = buttonList.GetChildren();
                    foreach (UITestControl buttonGroup in buttonListChildren)
                    {
                        foreach (var potentialButton in buttonGroup.GetChildren())
                        {
                            if (potentialButton.GetChildren().Count > 0)
                            {
                                UITestControlCollection buttonProperties = potentialButton.GetChildren();
                                string friendlyName = buttonProperties[0].FriendlyName;
                                if (friendlyName == buttonText)
                                {
                                    return((UITestControl)buttonProperties[0]);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
Example #5
0
        private UITestControlCollection GetWebsiteGridBlocks(UITestControl theTab)
        {
            UITestControlCollection requiredChildren = GetDeployUserControlChildren(theTab);
            UITestControlCollection gridBlocks       = requiredChildren[0].GetChildren();

            return(gridBlocks);
        }
        public void testmethods()
        {
            ApplicationUnderTest note = ApplicationUnderTest.Launch("C:\\Windows\\System32\\notepad.exe");
            UITestControl        num  = new UITestControl();

            num.TechnologyName = "MSAA";
            num.SearchProperties[UITestControl.PropertyNames.Name] = "Untitled - Notepad";
            UITestControl           but     = new WinButton(num);
            UITestControlCollection control = but.FindMatchingControls();
            var controlbutton = control.GetNamesOfControls();

            foreach (var c in controlbutton)
            {
                Keyboard.SendKeys(c + "\n");
            }


            // var Ocr = new AutoOcr();
            //var Result = Ocr.Read(@"C:\Users\shravya.shastri\Desktop\qrcode.png");
            // Console.WriteLine(Result.Text);
            // string n = Result.ToString();
            // method.launch();
            // Keyboard.SendKeys(n);
            // method.filemethod();
            // method.savemethod();
            // method.scenarios();
            //mouse.rightclickmethod();
        }
Example #7
0
        // This method is only used once, so is currently hard-coded to return a specific block
        // - StudioBugTests.cs - OpeningOldWebPageTwiceRetainsData
        public UITestControl GetWebsiteGridBlock(UITestControl theTab)
        {
            UITestControlCollection blocks   = GetWebsiteGridBlocks(theTab);
            UITestControl           theBlock = blocks[0]; // Weird Layout - Block 0 is 1,0 and not 0,0 as you'd think

            return(theBlock);
        }
Example #8
0
        public string GetInputMappingToServiceValue(int rowNumber)
        {
            var rows = GetInputMappingRows();

            if (rows.Count >= rowNumber)
            {
                UITestControlCollection rowChildren    = rows[rowNumber - 1].GetChildren();
                List <UITestControl>    cells          = rowChildren.Where(c => c.ControlType == ControlType.Cell).ToList();
                UITestControlCollection cellChildren   = cells[1].GetChildren();
                UITestControl           firstOrDefault = cellChildren.FirstOrDefault(c => c.ControlType == ControlType.Text && c.FriendlyName != "*");
                if (firstOrDefault != null)
                {
                    WpfText wpfText = firstOrDefault as WpfText;
                    if (wpfText != null)
                    {
                        return(wpfText.DisplayText);
                    }
                }
            }
            else
            {
                throw new Exception("The row could not be found.");
            }
            return(null);
        }
        public int CountRows()
        {
            WpfWindow debugWindow           = GetDebugWindow();
            UITestControlCollection rowList = debugWindow.GetChildren()[1].GetChildren()[0].GetChildren()[1].GetChildren();

            return(rowList.Count);
        }
Example #10
0
        public UITestControl GetLastStep()
        {
            UITestControlCollection uiTestControlCollection = GetOutputWindow();

            Assert.IsTrue(uiTestControlCollection.Count > 0);
            return(uiTestControlCollection[uiTestControlCollection.Count - 1]);
        }
        /// <summary>
        /// Deletes the index of the data grid view by.
        /// </summary>
        /// <param name="data">The data.</param>
        public static void DeleteDataGridViewByIndex(string[] data)
        {
            WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), data[0], _root);
            WinRow   row   = new WinRow(table);

            if (data[3] == string.Empty)
            {
                Mouse.Click(table, System.Windows.Forms.MouseButtons.Right);
            }
            else
            {
                row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, data[3]);
                row.Find();
                UITestControlCollection collection = row.GetChildren();
                Mouse.Click(collection[0]);
                Mouse.Click(collection[0], System.Windows.Forms.MouseButtons.Right);
            }
            WinWindow window = new WinWindow();
            WinMenu   menu   = new WinMenu(window);

            menu.SearchProperties[WinMenu.PropertyNames.Name] = data[1];
            WinMenuItem item = new WinMenuItem(menu);

            item.SearchProperties[WinMenuItem.PropertyNames.Name] = data[2];
            Mouse.Click(item);
        }
Example #12
0
        public UITestControl GetDestinationContolByFriendlyName(UITestControl theTab, string controlName)
        {
            UITestControlCollection requiredChildren = GetDeployUserControlChildren(theTab);

            return((from theControl in requiredChildren
                    where theControl.GetProperty("AutomationId").ToString() == "ConnectUserControl"
                    select theControl.GetChildren().FirstOrDefault(c => c.FriendlyName == controlName && ((WpfControl)c).AutomationId.Contains("Destination"))).FirstOrDefault());
        }
Example #13
0
        public void ClickScalarVariableName(int position)
        {
            // The actual box is item [1];
            UITestControlCollection variableList = GetScalarVariableList();
            UITestControl           theBox       = variableList[position].GetChildren().FirstOrDefault(c => c.ControlType == ControlType.Edit);

            Mouse.Click(theBox, new Point(5, 5));
        }
        public void ResizeAdornerMappings_Expected_AdornerMappingIsResized()
        {
            const string resourceToUse = "Bug_10528";
            const string innerResource = "Bug_10528_InnerWorkFlow";

            // Open the Explorer
            ExplorerUIMap.EnterExplorerSearchText(resourceToUse);

            ExplorerUIMap.DoubleClickOpenProject("localhost", "INTEGRATION TEST SERVICES", resourceToUse);
            UITestControl theTab = TabManagerUIMap.GetActiveTab();

            UITestControl controlOnWorkflow = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, innerResource);

            Mouse.Move(controlOnWorkflow, new Point(5, 5));
            Mouse.DoubleClick();

            UITestControlCollection controlCollection = controlOnWorkflow.GetChildren();
            Point initialResizerPoint = new Point();
            // Validate the assumption that the last child is the resizer
            var resizeThumb = controlCollection[controlCollection.Count - 1];

            if (resizeThumb.ControlType.ToString() == "Indicator")
            {
                if (resizeThumb.BoundingRectangle.X == -1)
                {
                    Assert.Fail("Resize indicator is not visible");
                }

                initialResizerPoint.X = resizeThumb.BoundingRectangle.X + 5;
                initialResizerPoint.Y = resizeThumb.BoundingRectangle.Y + 5;
            }
            else
            {
                Assert.Fail("Cannot find resize indicator");
            }

            // Drag
            Mouse.Move(new Point(resizeThumb.Left + 5, resizeThumb.Top + 5));
            Mouse.Click();
            Mouse.StartDragging();

            // Y - 50 since it starts at the lowest point
            Mouse.StopDragging(new Point(initialResizerPoint.X + 50, initialResizerPoint.Y + 50));

            // Check position to see it dragged
            Point newResizerPoint = new Point();

            if (resizeThumb.ControlType.ToString() == "Indicator")
            {
                newResizerPoint.X = resizeThumb.BoundingRectangle.X + 5;
                newResizerPoint.Y = resizeThumb.BoundingRectangle.Y + 5;
            }

            if (!(newResizerPoint.X > initialResizerPoint.X) || !(newResizerPoint.Y > initialResizerPoint.Y))
            {
                Assert.Fail("The control was not resized properly.");
            }
        }
        public void UITestControlCollection_CanClearCollection()
        {
            UITestControlCollection siblings = CheckBox.GetParent().GetChildren();

            siblings.Should().NotBeNullOrEmpty("because the CheckBox should have siblings");

            siblings.Clear();
            siblings.Should().BeEmpty("because we cleared the collection");
        }
Example #16
0
        /// <summary>
        ///     Get all the children of a control of a given type.
        ///     It can returns only direct children or all of them.
        /// </summary>
        /// <typeparam name="T">The aimed type of child.</typeparam>
        /// <param name="onlyDirectChildren">Do you want only direct children ?</param>
        /// <param name="control">The target control.</param>
        /// <returns>The children of the aimed type. An empty list if there is none.</returns>
        public static List <T> GetChildren <T>(this WpfControl control, bool onlyDirectChildren = true)
            where T : WpfControl
        {
            UITestControlCollection children = control.GetChildren();
            var controls = new List <T>();

            GetChildren(children, controls, onlyDirectChildren);
            return(controls);
        }
Example #17
0
        public string GetVariableName(int position)
        {
            UITestControlCollection variableList = GetScalarVariableList();
            UITestControl           theBox       = variableList[position].GetChildren()[1];

            string boxText = theBox.GetText();

            return(boxText);
        }
Example #18
0
        public UITestControlCollection GetWorkflowSteps(UITestControl theWorkflow, string controlId)
        {
            var stepSearcher = new UITestControl(theWorkflow);

            stepSearcher.SearchProperties.Add("AutomationId", controlId, PropertyExpressionOperator.Contains);
            UITestControlCollection steps = stepSearcher.FindMatchingControls();

            return(steps);
        }
        public bool CloseTab_Click_No(UITestControl theTab)
        {
            if (CloseTab(theTab))
            {
                UITestControlCollection saveDialogButtons = null;
                try
                {
                    var tabNameControl = theTab.GetChildren().FirstOrDefault(c => c.ClassName == "Uia.TextBlock");
                    if (tabNameControl != null)
                    {
                        if (tabNameControl.FriendlyName.EndsWith("*"))
                        {
                            saveDialogButtons = GetWorkflowNotSavedButtons();
                        }
                        else if (tabNameControl.FriendlyName == "Scheduler")
                        {
                            saveDialogButtons = GetWorkflowNotSavedButtons("Scheduler Task has changes");
                        }
                        else if (tabNameControl.FriendlyName == "Settings")
                        {
                            saveDialogButtons = GetWorkflowNotSavedButtons("Security Settings have changed");
                        }
                    }
                }
                catch (Exception)
                {
                    return(true);
                    //This is empty because if the pop cant be found then the tab must just close;)
                }
                // Only if we expect a save dialog should we search for it ;)
                if (saveDialogButtons != null)
                {
                    try
                    {
                        if (saveDialogButtons.Count > 0)
                        {
                            UITestControl theBtn = saveDialogButtons[1];
                            Point         p      = new Point(theBtn.Left + 25, theBtn.Top + 15);
                            Mouse.MouseMoveSpeed = 10000;
                            Mouse.Move(p);
                            Mouse.Click();
                            return(true);
                        }
                    }
                    catch (Exception)
                    {
                        return(true);
                        //This is empty because if the pop cant be found then the tab must just close;)
                    }
                }

                return(true);
            }

            return(false);
        }
Example #20
0
        public static void DeleteDataGridViewRowByIndex(string name, string index)
        {
            WinTable table = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root);
            WinRow   row   = new WinRow(table);

            row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, index);
            UITestControlCollection collection = row.GetChildren();

            Mouse.Click(collection[0]);
        }
Example #21
0
        public string[] GetContent()
        {
            UITestControlCollection items = this.Items;

            if (items != null)
            {
                return(items.GetNamesOfControls());
            }
            return(null);
        }
        /// <summary>
        /// Clicks the data grid view cell.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="cellIndex">Index of the cell.</param>
        public static void ClickDataGridViewCell(string name, string rowIndex, string cellIndex)
        {
            WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), name, _root);
            WinRow   row   = new WinRow(table);

            row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex);
            UITestControlCollection collection = row.GetChildren();

            Mouse.Click(collection[int.Parse(cellIndex)]);
        }
Example #23
0
        public void EnterTextIntoRecordsetName(int indexNumber, string stringToEnter)
        {
            UITestControlCollection variableList = GetRecordsetVariableList();
            UITestControl           theBox       = variableList[indexNumber].GetChildren().FirstOrDefault(c => c.ControlType == ControlType.Edit);

            if (theBox != null)
            {
                theBox.EnterText(stringToEnter);
            }
        }
        public static void NavigateLinks()
        {
            string linkText = Data.GetValue("ResultLinksText");

            // ObjectIdentification.UpdateSearchProperties(linkText);
            ObjectIdentification.AddUpdateSearchProperties(BING.SearchResultsUI.resultLink, "InnerText", linkText);
            UITestControlCollection col = BING.SearchResultsUI.resultLink.FindMatchingControls();

            Mouse.Click(BING.SearchResultsUI.resultLink);
        }
Example #25
0
        public string[] GetColumnNames()
        {
            UITestControlCollection columnHeaders = this.ColumnHeaders;

            if (columnHeaders != null)
            {
                return(columnHeaders.GetNamesOfControls());
            }
            return(null);
        }
Example #26
0
        public string[] GetContent()
        {
            UITestControlCollection cells = Cells;

            if (cells != null)
            {
                return(cells.GetValuesOfControls());
            }
            return(null);
        }
        protected UITestControl GetQuickVariableInputView()
        {
            UITestControlCollection uiTestControlCollection = Activity.GetChildren();
            UITestControl           firstOrDefault          = uiTestControlCollection.FirstOrDefault(c => ((WpfControl)c).AutomationId == "QuickVariableInputContent");

            if (firstOrDefault != null)
            {
                return(firstOrDefault);
            }
            throw new Exception("Couldnt find the quick variable input view");
        }
Example #28
0
        public void HtmlEdit_SetText_Succeeds()
        {
            GoogleHomePage pgGHomePage = WebPage.Launch <GoogleHomePage>("http://www.google.com");

            pgGHomePage.txtSearch.SetText("Coded UI Test Framework");
            GoogleSearch            pgSearch = WebPage.GetPage <GoogleSearch>();
            UITestControlCollection col      = pgSearch.divSearchResults.UnWrap().GetChildren();

            //do something with collection
            pgSearch.Close();
        }
Example #29
0
        public void ClickRecordSetName(int recSetIndex)
        {
            UITestControlCollection variableList = GetRecordsetVariableList();
            UITestControl           theBox       = variableList[recSetIndex].GetChildren().FirstOrDefault(c => c.ControlType == ControlType.Edit);

            if (theBox != null)
            {
                Point p = new Point(theBox.BoundingRectangle.X, theBox.BoundingRectangle.Y);
                Mouse.Click(new Point(p.X + 25, p.Y + 5));
            }
        }
        public void UITestControlCollection_IsRead()
        {
            UITestControlCollection siblings = CheckBox.GetParent().GetChildren();

            siblings.Should().NotBeNullOrEmpty("because the CheckBox should have siblings");

            siblings
            .IsReadOnly
            .Should()
            .BeFalse("because it's possible to edit the collection.");
        }
        private UITestControlCollection getRibbonItemListFromMenuName(string menuName)
        {
            UITestControlCollection theCollection = new UITestControlCollection();
            WpfTabList uIRibbonTabList = this.UIBusinessDesignStudioWindow.UIRibbonTabList;

            for (int j = 0; j < uIRibbonTabList.Tabs.Count; j++)
            {
                if (uIRibbonTabList.Tabs[j].FriendlyName == menuName)
                {
                    theCollection = uIRibbonTabList.Tabs[j].GetChildren();
                    break;
                }
            }
            return theCollection;
        }
        public UITestControlCollection GetRecordsetVariableList()
        {
            UITestControl variableMenu = GetRecordsetVariables();

            UITestControlCollection variableList = variableMenu.GetChildren();
            UITestControlCollection returnList = new UITestControlCollection();
            foreach(UITestControl theItem in variableList)
            {
                if(theItem.ControlType == ControlType.TreeItem)
                {
                    returnList.Add(theItem);
                }
            }

            return returnList;
        }
Example #33
0
 public static UITestControlCollection GetInputDetailsDetails(UITestControl outputWindow)
 {
     var coll = outputWindow.GetChildren();
     var results = new UITestControlCollection();
     for(int i = 0; i <= coll.Count; i++)
     {
         if(coll[i].Name.Equals("Inputs : "))
         {
             int j = 1;
             while(!coll[i + j].Name.Equals("Outputs : "))
             {
                 if(coll[i + j].ControlType != ControlType.Button)
                     results.Add(coll[i + j]);
                 j++;
             }
             return results;
         }
     }
     return results;
 }
Example #34
0
        /// <summary>
        /// Gets the navigation items.
        /// </summary>
        /// <returns></returns>
        public UITestControlCollection GetServiceItems()
        {
            UITestControlCollection categories = _explorerTree.GetChildren();

            UITestControlCollection categoryCollection = new UITestControlCollection();

            foreach(UITestControl category in categories)
            {
                if(category.ControlType.ToString() == "TreeItem")
                {
                    var kids = category.GetChildren();
                    foreach(var kid in kids)
                    {
                        if(kid.ControlType.ToString() == "TreeItem")
                        {
                            categoryCollection.Add(kid);
                        }
                    }

                }
            }

            return categoryCollection;
        }
Example #35
0
        /// <summary>
        /// Gets the navigation item categories.
        /// </summary>
        /// <returns></returns>
        public UITestControlCollection GetNavigationItemCategories()
        {
            UITestControlCollection categories = _explorerTree.GetChildren();

            UITestControlCollection categoryCollection = new UITestControlCollection();

            foreach(UITestControl category in categories)
            {
                if(category.ControlType.ToString() == "TreeItem")
                {
                    categoryCollection.Add(category);
                }
            }

            return categoryCollection;
        }
 public static void WaitCountNotEqualTo(int notExpectedCount, UITestControlCollection collection)
 {
     int retryTimes = int.Parse(ConfigurationManager.AppSettings["DefaultPollingRetryTime"]);
     while ((collection.Count == notExpectedCount) && (retryTimes--) != 0)
     {
         System.Threading.Thread.Sleep(int.Parse(ConfigurationManager.AppSettings["DefaultPollingRetryWaitTime"]));
     }
     if (retryTimes == 0)
     {
         throw new UITestException("Fail to wait the count of collection not equal to " + notExpectedCount);
     }
 }
        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;
        }
 /// <summary>
 /// Verifies direct children of App window by Name
 /// </summary>
 /// <param name="ChildName"></param>
 /// <returns></returns>
 public static void ClickAppChildrenByName(string ChildName)
 {
     Logger.InsertLogLine("Click Children control of App by Name " + ChildName);
     UITestControlCollection children = new UITestControlCollection();
     children = xamlAppWindow.GetChildren();
     for (int i = 0; i < children.Count; i++)
     {
         string chname = children[i].Name;
         if (children[i].Name.Contains(ChildName))
         {
             Gesture.Tap(new Point(children[i].BoundingRectangle.X + children[i].BoundingRectangle.Width / 2, children[i].BoundingRectangle.Y + children[i].BoundingRectangle.Height / 2));
         }
     }
 }
        public UITestControlCollection GetStepInOutputWindow(UITestControl outputWindow, string stepToFind)
        {
            UITestControlCollection coll = outputWindow.GetChildren();
            UITestControlCollection results = new UITestControlCollection();
            foreach(var child in coll)
            {
                if(child.Name.Equals(stepToFind))
                {
                    results.Add(child);
                }
            }

            return results;
        }
        public void AssignControl_QuickVariableInputControl_EnterData(UITestControl theTab, string controlAutomationId, string splitOn, string prefix, string suffix, string variableList)
        {
            // Find the control
            UITestControl assignControl = FindControlByAutomationId(theTab, controlAutomationId);
            UITestControlCollection assignControlCollection = assignControl.GetChildren();
            var qviControl = GetQVIControl(assignControlCollection);

            UITestControlCollection qviChildren = qviControl.GetChildren();

            UITestControlCollection textBoxes = new UITestControlCollection();
            foreach(UITestControl theControl in qviChildren)
            {
                if(theControl.ControlType == ControlType.Edit)
                {
                    textBoxes.Add(theControl);
                }
            }

            if(textBoxes.Count == 0)
            {
                Assert.Fail("Cant find QVI textboxes");
            }


            Mouse.Click(textBoxes[0], new Point(15, 5));
            Playback.Wait(250);
            SendKeys.SendWait(variableList.Replace("(", "{(}").Replace(")", "{)}"));
            Playback.Wait(250);
            SendKeys.SendWait("{TAB}{TAB}");
            Playback.Wait(250);
            // And enter all the data
            SendKeys.SendWait(splitOn.Replace("(", "{(}").Replace(")", "{)}"));
            Playback.Wait(250);
            SendKeys.SendWait("{TAB}");
            Playback.Wait(250);
            SendKeys.SendWait(prefix.Replace("(", "{(}").Replace(")", "{)}"));
            Playback.Wait(250);
            SendKeys.SendWait("{TAB}");
            Playback.Wait(250);
            SendKeys.SendWait(suffix.Replace("(", "{(}").Replace(")", "{)}"));
        }
        /// <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;
        }
        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));
                }
            }
        }
 /// <summary>
 /// Verifies direct children of App window by Name
 /// </summary>
 /// <param name="ChildName"></param>
 /// <returns></returns>
 public static bool VerifyAppChildrenByName(string ChildName)
 {
     Logger.InsertLogLine("Verify Children control of App by Name " + ChildName);
     UITestControlCollection children = new UITestControlCollection();
     children = xamlAppWindow.GetChildren();
     for (int i = 0; i < children.Count; i++)
     {
         string chname = children[i].Name;
         if (children[i].Name.Contains(ChildName))
         {
             return true;
     }
     }
     return false;
 }
        /// <summary>
        /// Runs the workflow and wait until output step count attribute least.
        /// </summary>
        /// <param name="expectedStepCount">The expected step count.</param>
        /// <param name="timeout">The timeout.</param>
        /// <exception cref="Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException">Debug input dialog not shown within the given timeout</exception>
        public void RunWorkflowAndWaitUntilOutputStepCountAtLeast(int expectedStepCount, int timeout = 5000)
        {
            SendKeys.SendWait("{F5}");
            if(DebugUIMap.WaitForDebugWindow(5000))
            {
                SendKeys.SendWait("{F6}");
            }
            else
            {
                throw new UITestControlNotFoundException("Debug input dialog not shown within the given timeout");
            }

            var steps = new UITestControlCollection();
            var count = 0;
            while(steps.Count < expectedStepCount && count <= timeout)
            {
                Playback.Wait(100);
                steps = OutputUIMap.GetOutputWindow();
                count++;
            }
        }
        /// <summary>
        /// Gets the qvi control.
        /// </summary>
        /// <param name="assignControlCollection">The assign control collection.</param>
        /// <returns></returns>
        static UITestControl GetQVIControl(UITestControlCollection assignControlCollection)
        {
            UITestControl qviControl = null;

            foreach(UITestControl theControl in assignControlCollection)
            {
                if(theControl.FriendlyName == "QuickVariableInputContent")
                {
                    qviControl = theControl;
                    break;
                }
            }
            if(qviControl == null)
            {
                Assert.Fail("Cant find quick variable input control");
            }
            return qviControl;
        }
 private UITestControlCollection GetCellsFromFirstRow(UITestControlCollection rows)
 {
     if (rows.Count < 1)
     {
         throw new Exception("There is no account information in job grid view!");
     }
     WinRow firstRow = rows[0] as WinRow;
     Assert.AreEqual(3, firstRow.Cells.Count, "The count of cell in job grid view should be equal to 3!");
     return firstRow.Cells;
 }
        private UITestControlCollection GetWorkflowNotSavedButtons(string windowTitle = "Workflow not saved...")
        {
            // Workflow not saved...
            UITestControl theWindow = new UITestControl();
            theWindow.TechnologyName = "MSAA";
            theWindow.SearchProperties["Name"] = windowTitle;
            theWindow.SearchProperties["ControlType"] = "Window";
            theWindow.Find();
            UITestControlCollection firstChildren = theWindow.GetChildren();

            var ctrls = firstChildren.Where(c => c.ClassName == "Uia.Button");

            UITestControlCollection saveDialogButtons = new UITestControlCollection();
            foreach(UITestControl control in ctrls)
            {
                saveDialogButtons.Add(control);
            }

            return saveDialogButtons;
        }
        public UITestControlCollection GetStepsByFriendly(UITestControl outputWindow, string friendlyName)
        {
            var children = outputWindow.GetChildren().Where(c => c.FriendlyName.Equals(friendlyName, StringComparison.CurrentCultureIgnoreCase));
            var uiCollection = new UITestControlCollection();

            foreach(var child in children)
            {
                uiCollection.Add(child);
            }

            return uiCollection;
        }
Example #49
0
 public UITestControlCollection GetAllTools()
 {
     UITestControlCollection result = new UITestControlCollection();
     foreach(var category in _toolTree.GetChildren())
     {
         var tools = category.GetChildren();
         if(tools.Count > 0)
         {
             foreach(var tool in tools)
             {
                 if(tool.ControlType == ControlType.TreeItem)
                 {
                     result.Add(tool);
                 }
             }
         }
     }
     return result;
 }
        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));
                }
            }
        }