Example #1
0
        public static TreeItem GetChildItem(this Ranorex.TreeItem item, string key, bool expand = true)
        {
            TreeItem childItem = null;

            try
            {
                foreach (var child in item.Items)
                {
                    if (child.Text == key)
                    {
                        if (expand)
                        {
                            child.Expand();
                        }
                        childItem = child;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Failed : GetChildItem : " + ex.Message);
            }
            return(childItem);
        }
Example #2
0
 public static bool ClickThis(this Ranorex.TreeItem item)
 {
     System.Threading.Thread.Sleep(200);
     item.Click();
     System.Threading.Thread.Sleep(200);
     return(true);
 }
Example #3
0
        public static TreeItem GetItem(this Ranorex.TreeItem treeitem, string dbkey, bool isExpand = true)
        {
            TreeItem item = null;

            try
            {
                foreach (var itemtree in treeitem.Items)
                {
                    if (itemtree.Text.Trim() == dbkey)
                    {
                        if (isExpand)
                        {
                            itemtree.EnsureVisible();
                            itemtree.Expand();
                        }
                        item = itemtree;
                        System.Threading.Thread.Sleep(1000);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("TreeItem Get Item Failed : " + ex.Message);
            }
            return(item);
        }
Example #4
0
        //**********************************************************************
        /// <summary>
        /// Click to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void Select_Item(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if (objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='" + item.getArgText() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter <Ranorex.ListItem>(true);
                targetListItem.Click();
            }

            if (objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                               objComponetInfo.Path + "/row/cell[@text='" + item.getArgText() + "']",
                                                               10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter <Ranorex.Cell>(true);
                targetCell.Click();
            }

            if (objType.Name.ToString() == "Tree")
            {
                int    treeLevel       = Convert.ToInt32(item.getArgText());
                string strTreelevel    = "";
                string strTreelevelCkb = "";
                for (int i = 1; i <= treeLevel; i++)
                {
                    strTreelevel    += "/treeitem";
                    strTreelevelCkb += "/checkbox";
                }

                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel + "[@accessiblename='" + item.getArg2Text() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());

                if (targetTreeItemInfo.Exists())
                {
                    Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter <Ranorex.TreeItem>(true);
                    targetTreeItem.Click();
                }
                else
                {
                    targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem1",
                                                          objComponetInfo.Path + strTreelevelCkb + "[@accessiblename='" + item.getArg2Text() + "']",
                                                          10000, null, System.Guid.NewGuid().ToString());
                    Ranorex.CheckBox targetTreeItemCkb = targetTreeItemInfo.CreateAdapter <Ranorex.CheckBox>(true);
                    targetTreeItemCkb.Click();
                }
            }
        }
Example #5
0
 public static void RightClick(this Ranorex.TreeItem item)
 {
     try
     {
         Mouse.Click(item, System.Windows.Forms.MouseButtons.Right, new Point(30, 10));
         Sleep();
     }
     catch (Exception ex)
     {
         throw new Exception("TreeItem Right Click failed : " + ex.Message);
     }
 }
Example #6
0
 public static void ClickThis(this Ranorex.TreeItem item)
 {
     try
     {
         item.Click();
         Sleep();
     }
     catch (Exception ex)
     {
         throw new Exception("TreeItem Click Failed : " + ex.Message);
     }
 }
Example #7
0
        //**********************************************************************
        /// <summary>
        /// DoubleClick to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void DoubleClick_Item(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if (objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='" + item.getArgText() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter <Ranorex.ListItem>(true);
                targetListItem.DoubleClick();
            }

            if (objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                               objComponetInfo.Path + "/row/cell[@text='" + item.getArgText() + "']",
                                                               10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter <Ranorex.Cell>(true);
                targetCell.DoubleClick();
            }

            if (objType.Name.ToString() == "Tree")
            {
                int    treeLevel    = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                for (int i = 1; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                }
                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel + "[@accessiblename='" + item.getArg2Text() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter <Ranorex.TreeItem>(true);
                targetTreeItem.DoubleClick();

                /*
                 *           Ranorex.Control treeViewControl = targetTreeItem.Element.As<Ranorex.Control>();
                 *                           System.Windows.Forms.TreeNode node = treeViewControl.InvokeMethod(
                 *                           "GetNodeAt",
                 *                           new object[] { targetTreeItem.Element.ClientRectangle.Location + new Size(1, 1) })
                 *                               as System.Windows.Forms.TreeNode;
                 *           object mynode = node.GetLifetimeService();
                 *           Ranorex.CheckBox mycheckbox = (Ranorex.CheckBox)mynode;
                 *           mycheckbox.Check();
                 */
            }
        }
Example #8
0
 public static bool RightClick(this Ranorex.TreeItem item)
 {
     Mouse.Click(item, System.Windows.Forms.MouseButtons.Right, new Point(30, 10));
     return(true);
 }