예제 #1
0
        public void CheckRegistryKeyExist()
        {
            string regKey = @"HKEY_LOCAL_MACHINE/SOFTWARE/Dell/Dell Help & Support";

            // open regedit
            Keyboard.Press("{LWin down}r{LWin up}");
            Delay.Milliseconds(1000);

            Keyboard.Press("regedit");
            Delay.Milliseconds(200);

            Keyboard.Press("{Return}");
            Delay.Milliseconds(200);

            // click Computer Root Item
            TreeItem parentKey = repo.RegistryEditor.Computer.FindSingle(".");

            ExpandRegTreeItem(parentKey);

            // split path into item
            string[] key = regKey.Split('/');

            Report.Info("Check the Registry items of DHS");
            for (int i = 0; i < key.Count(); i++)
            {
                // select & open child key
                string   childKeyXpath = @"./treeitem[@text='" + key[i] + "']";
                TreeItem childKey      = null;
                try{
                    childKey = parentKey.FindSingle(childKeyXpath);
                }
                catch (ElementNotFoundException) {
                    // report failure
                    Report.Log(ReportLevel.Failure, "Registry KEY not found: " + key[i]);
                    break;
                }
                childKey.Click();
                ExpandRegTreeItem(childKey);
                Delay.Milliseconds(500);
                parentKey = childKey;
                if (i == key.Count() - 1)
                {
                    // report success
                    Report.Log(ReportLevel.Success, "Registry KEY found: " + regKey);
                }
            }
            // close registry window
            repo.RegistryEditor.Close.Click();
        }
예제 #2
0
 public void ExpandRegTreeItem(TreeItem item)
 {
     item.Click(System.Windows.Forms.MouseButtons.Right);
     // expand key
     try{
         repo.Regedit.ExpandInfo.WaitForExists(500);
         if (repo.Regedit.Expand.Enabled)
         {
             repo.Regedit.Expand.Click();
         }
         else
         {
             Keyboard.Press("{Escape}");
         }
     }
     catch (RanorexException) {
         Keyboard.Press("{Escape}");
     }
 }
        /// <summary>
        ///     Search specified parameter via parameter page -> navigation area -> tree
        /// </summary>
        /// <param name="path">Tree path to and including parameter</param>
        /// <returns>
        ///     <br>True: If everything worked fine</br>
        ///     <br>False: If an error occurred</br>
        /// </returns>
        public bool SearchAndSelectParameter(string path)
        {
            string[] seperator     = { "//" };
            string[] pathParts     = path.Split(seperator, StringSplitOptions.None);
            string   parameterName = pathParts[pathParts.Length - 1];

            // Get parameter in navigation area
            TreeItem treeItem = this.GetTreeItemByPath(path);

            if (treeItem != null)
            {
                // Select TreeItem to enable parameter related page at application area
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter [" + parameterName + "] is found.");
                var location = new Location(treeItem.Element.Size.Width / 3, treeItem.Element.Size.Height - (treeItem.Element.Size.Height - 1));
                treeItem.Click(location);
                return(true);
            }

            // Return feedback that parameter is not found
            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Path [" + path + "] is not valid.");
            return(false);
        }
예제 #4
0
        public static void RightClickOnServer(string serverName)
        {
            try
            {
                var allServers = repo.Application.AllServers;
                Report.Info(allServers.Items.Count.ToString());
                if (allServers.Items.Count >= 1)
                {
                    //					allServers.Items[0].Click(System.Windows.Forms.MouseButtons.Right);
                    //					Reports.ReportLog("Clicked Server ", Reports.SQLdmReportLevel.Success, null, Config.TestCaseName);
                }

                repo.Application.AllServersInfo.WaitForItemExists(120000);
                TreeItem serveritem = repo.Application.AllServers.GetChildItem(serverName);
                if (serveritem != null)
                {
                    serveritem.Click(System.Windows.Forms.MouseButtons.Right);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Failed : ClickOnAllServers : " + ex.Message);
            }
        }
        /// <summary>
        /// The handle tree item.
        /// </summary>
        /// <param name="treeItem">
        /// The tree item.
        /// </param>
        private void HandleTreeItem(TreeItem treeItem)
        {
            string parameterName;

            try
            {
                if (treeItem != null)
                {
                    string accessibleName = treeItem.Element.GetAttributeValueText("AccessibleName");
                    if (accessibleName != null)
                    {
                        parameterName = treeItem.Children[0].Element.GetAttributeValueText("Text");
                        if (parameterName != null)
                        {
                            // If tree item is a menu and not a parameter
                            if (accessibleName.Contains("Navigation_Menu_"))
                            {
                                this.numberOfMenus++;
                                Log.Info("Menu Name:", parameterName);
                                Mouse.MoveTo(treeItem.Children[0]);
                                this.navigationArea.ExpandMenu(treeItem);

                                // Mouse.DoubleClick(treeItem.Children[0]);
                                Thread.Sleep(500);
                                if (!this.areParameterInTree)
                                {
                                    Mouse.Click(treeItem);
                                    this.HandleApplicationArea();
                                }
                            }
                            else if (accessibleName.Contains("Navigation_Variable"))
                            {
                                this.numberOfParameter++;

                                string[] accessibleNameParts = accessibleName.Split('_');
                                string   parameterStatus     = accessibleNameParts[accessibleNameParts.Length - 1];

                                Stopwatch stopwatch = new Stopwatch();
                                stopwatch.Start();

                                while (parameterStatus.Equals("Insecure"))
                                {
                                    if (stopwatch.ElapsedMilliseconds > 30000)
                                    {
                                        treeItem.Click();
                                    }

                                    accessibleName      = treeItem.Element.GetAttributeValueText("AccessibleName");
                                    accessibleNameParts = accessibleName.Split('_');
                                    parameterStatus     = accessibleNameParts[accessibleNameParts.Length - 1];
                                }

                                stopwatch.Stop();

                                Log.Info(string.Format("Parameter Status: {1} \t\t, Parameter Name: {0}", parameterName, parameterStatus));

                                // "Insecure", "Invalid", "Valid", "Modified", "Dynamic1" or "Dynamic2"
                                switch (parameterStatus)
                                {
                                case "Insecure":
                                {
                                    this.numberOfParameterInsecure++;
                                    break;
                                }

                                case "Invalid":
                                {
                                    this.navigationArea.listOfInvalidParameters.Add(parameterName);
                                    this.numberOfParameterInvalid++;
                                    break;
                                }

                                case "Valid":
                                {
                                    this.numberOfParameterValid++;
                                    break;
                                }

                                case "Modified":
                                {
                                    this.numberOfParameterModified++;
                                    break;
                                }

                                case "Dynamic1":
                                {
                                    this.numberOfParameterDynamic++;
                                    break;
                                }

                                case "Dynamic2":
                                {
                                    this.numberOfParameterDynamic++;
                                    break;
                                }
                                }
                            }
                            else
                            {
                                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "TreeItem is not Menu or Parameter");
                            }
                        }
                    }
                    else
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "AccessibleName is null");
                    }
                }
                else
                {
                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "TreeItem is null");
                }
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Counter: " + this.counter.ToString(CultureInfo.InvariantCulture));
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Number of tree items: " + this.numberOfChildsBeforeUpdate.ToString(CultureInfo.InvariantCulture));
                Log.Info(string.Empty, exception.Message);
                throw;
            }
        }
        /// <summary>
        ///     Search and returns a tree item behind a specified path.
        /// </summary>
        /// <param name="strPath">Item (menu / parameter) to search for.</param>
        /// <returns>
        ///     <br>TreeItem: If call worked fine</br>
        ///     <br>Null: If an error occurred</br>
        /// </returns>
        private TreeItem GetTreeItemByPath(string strPath)
        {
            string[] seperator = { "//" };
            string[] pathParts = strPath.Split(seperator, StringSplitOptions.None);

            int      counter = 0;
            int      lastFoundTreeItemChildIndex = -1;
            TreeItem lastFoundTreeItem           = null;
            TreeItem treeItem = null;

            try
            {
                for (counter = 0; counter < pathParts.Length; counter++)
                {
                    // Get treeitem if it is visible at current GUI
                    treeItem = NavigationElements.GetTreeItem(pathParts[counter], lastFoundTreeItemChildIndex);

                    if (counter == pathParts.Length - 2 && treeItem != null)
                    {
                        treeItem.Click();
                        Parameter parameter = new Application().GetParameterStateFast(pathParts[pathParts.Length - 1]);
                        if (parameter.ParameterState != ParameterState.NotRecognized)
                        {
                            return(treeItem);
                        }
                    }

                    if (treeItem == null)
                    {
                        // If scrollbar active and not null
                        if (NavigationElements.VerticalScrollbar != null && NavigationElements.VerticalScrollbar.Enabled)
                        {
                            if (NavigationElements.PageUpButton.ScreenRectangle.Size.Height == 0)
                            {
                                // If scrollbar is on top
                                // Scroll down
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageDownButton, pathParts[counter], lastFoundTreeItemChildIndex);
                            }
                            else if (NavigationElements.PageDownButton.ScreenRectangle.Size.Height == 0)
                            {
                                // If scrollbar is on bottom
                                // Scroll up
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageUpButton, pathParts[counter], lastFoundTreeItemChildIndex);
                            }
                            else if (NavigationElements.PageUpButton.ScreenRectangle.Size.Height <=
                                     NavigationElements.PageDownButton.ScreenRectangle.Size.Height)
                            {
                                // If scrollbar is nearly on top
                                // Scroll down first
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageDownButton, pathParts[counter], lastFoundTreeItemChildIndex);

                                // Scroll up as next if treeItem noch found
                                if (treeItem == null)
                                {
                                    treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageUpButton, pathParts[counter], lastFoundTreeItemChildIndex);
                                }
                            }
                            else if (NavigationElements.PageUpButton.ScreenRectangle.Size.Height >
                                     NavigationElements.PageDownButton.ScreenRectangle.Size.Height)
                            {
                                // If scrollbar is nearly on bottom
                                // Scroll down first
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageDownButton, pathParts[counter], lastFoundTreeItemChildIndex);

                                // Scroll up as next if treeItem noch found
                                if (treeItem == null)
                                {
                                    treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageUpButton, pathParts[counter], lastFoundTreeItemChildIndex);
                                }
                            }
                            else
                            {
                                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Impossible path at if-then-else structure.");
                            }
                        }
                        else
                        {
                            // if Scrollbar not active search for treeitem with index greater than last found
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Treeitem " + "[" + pathParts[counter] + "]" + " not found");
                        }
                    }

                    if (treeItem != null)
                    {
                        treeItem.MoveTo();
                        lastFoundTreeItemChildIndex = treeItem.Element.ChildIndex;
                        lastFoundTreeItem           = treeItem;
                    }

                    if (counter >= (pathParts.Length - 1))
                    {
                        continue;
                    }

                    if (treeItem != null)
                    {
                        treeItem.Expand();
                    }
                }

                return(lastFoundTreeItem);
            }
            catch (Exception exception)
            {
                Log.Error("Navigation.GetTreeItemByPath@" + pathParts[counter], exception.Message);
                return(null);
            }
        }