/// <summary> /// Used for click on check box /// </summary> /// <param name="element">element xpath</param> /// <param name="state">for select=check and for diselect=uncheck</param> public static void checkbox(Ranorex.CheckBox element, string state) { Boolean beforeclick, afterclick; //create the checkbox from the repository try { Ranorex.CheckBox checkbox = element; if (checkbox.Checked) { if (state == "check") { } else { for (;;) { beforeclick = checkbox.Checked; checkbox.Click(); afterclick = checkbox.Checked; if (beforeclick == afterclick) { } else { break; } } } } else { if (state == "uncheck") { } else { for (;;) { beforeclick = checkbox.Checked; checkbox.Click(); afterclick = checkbox.Checked; if (beforeclick == afterclick) { } else { break; } } } } } catch (Exception e) { Report.Failure("Exception occured" + e.Message); } }
public static bool ClickThis(this Ranorex.CheckBox 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 ClickThis(this Ranorex.CheckBox item) { try { item.Click(); Sleep(); } catch (Exception ex) { throw new Exception("Checkbox Click Failed : " + ex.Message); } }