public static bool ClickThis(this Ranorex.ListItem item) { System.Threading.Thread.Sleep(200); item.Click(); System.Threading.Thread.Sleep(200); return(true); }
//********************************************************************** /// <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(); } } }
public static void Select(this Ranorex.ComboBox combobox, string item) { // create button Ranorex.Button mybutton = combobox.FindSingle(combobox.GetPath().ToString() + "/button[@accessiblename='Open' or @text='>']"); mybutton.Click(); // create list item to click on Ranorex.ListItem myList = combobox.FindSingle(String.Format("/list[@controlid='1000']/listitem[@text='{0}']", item)); myList.Click(); }
public static void RightClick(this Ranorex.ListItem item) { try { Mouse.Click(item, System.Windows.Forms.MouseButtons.Right, new Point(30, 10)); } catch (Exception ex) { throw new Exception("ListItem Right Click Failed : " + ex.Message); } }
public static void RightClickThis(this Ranorex.ListItem item) { try { item.RightClick(); Sleep(); } catch (Exception ex) { throw new Exception("ListItem Click Failed : " + ex.Message); } }
//********************************************************************** /// <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(); */ } }
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] + "']"; } } }
public static void Select_Device(string devicename) { Ranorex.Text DeviceselectionTextbox = "/form[@name~'Smart Fit' or @name~'Launcher' or @name~'Solus Max' or @name~'Interton Fitting' or @name~'Audigy' or @name~'Costco' or @classname='Window']/text"; Ranorex.Container DeviceContainer = "/contextmenu[@processname~'SmartFit' or @processname~'SolusMax' or @processname~'Audigy' or @processname~'Interton']/list/container/container"; IList <ListItem> txtlistitem = DeviceContainer.FindChildren <ListItem>(); for (int i = 0; i <= txtlistitem.Count - 1; i++) { int j = i + 1; Ranorex.ListItem device = "/contextmenu[@processname~'SmartFit' or @processname~'SolusMax' or @processname~'Audigy' or @processname~'Interton']/list/container/container/listitem[" + j + "]"; string k = device.Text; if (devicename == k || k == DeviceselectionTextbox.TextValue) { Mouse.Click(device); break; } } }
public static void EnglishCombo_click() { Ranorex.ListItem EnglishList="/form[@classname='Popup' and @orientation='None' and @processname='SmartFit']/container/listitem[1]"; Mouse.Click(EnglishList); }