Esempio n. 1
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();
                 */
            }
        }
Esempio n. 2
0
        public static void OpenFile(string path)
        {
            // press Window E open file explorer
            Ranorex.Keyboard.Press("{LWin down}e{LWin up}");
            Delay.Milliseconds(1000);

            System.Diagnostics.Debug.WriteLine(path);
            // split path into item
            string[] dir = path.Split('\\');
            string   fileExplorerXpath = null;

            for (int i = 0; i < dir.Length; i++)
            {
                System.Diagnostics.Debug.WriteLine(dir[i]);
                if (i == 0)
                {
                    repo.Explorer.ToolBar1001.Click();
                    Ranorex.Keyboard.Press(dir[i]);
                    Ranorex.Keyboard.Press("{Return}");
                    fileExplorerXpath = "/form[@processname='explorer' and @title='" + "OS (" + dir[i] + ")']";
                }
                else
                {
                    // find file explorer
                    Ranorex.Form         fileExplorer = null;
                    Ranorex.Core.Element element      = Host.Local.FindSingle(fileExplorerXpath, 5000);
                    if (element != null)
                    {
                        fileExplorer = element;
                    }
                    // check if folder exist
                    string folderXpath = "element[@class='ShellTabWindowClass']//element[@instance='1']/container[@caption='ShellView']/list/listitem[@text='" + dir[i] + "']";
                    try{
                        Ranorex.ListItem folder = fileExplorer.FindSingle <Ranorex.ListItem>(folderXpath, 5000);
                        folder.DoubleClick();
                        Delay.Milliseconds(500);
                    }
                    catch (ElementNotFoundException ex) {
                        // report fail
                        Report.Log(ReportLevel.Failure, "Folder not found: " + path);
                        throw ex;
                    }
                    fileExplorerXpath = "/form[@processname='explorer' and @title='" + dir[i] + "']";
                }
            }
        }
Esempio n. 3
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();
            }
        }