public static bool ClickThis(this Ranorex.CheckBox item) { System.Threading.Thread.Sleep(200); item.Click(); System.Threading.Thread.Sleep(200); return(true); }
/// <summary> /// This is used for validated check box status /// </summary> /// <param name="element">elemnt xpath</param> /// <param name="checkboxstate">checkbox status to vaildate</param> /// <param name="controlName">logical contol name</param> public static void validateCheckboxstatus(Ranorex.CheckBox element, string checkboxstate, string controlName) { Ranorex.CheckBox checkbox = element; if (checkbox.Checked) { if (checkboxstate == "check") { Report.Success(controlName + " is Checked"); } else if (checkboxstate == "uncheck") { Report.Failure(controlName + " Check box is Checked"); } } else if (!checkbox.Checked) { if (checkboxstate == "check") { Report.Failure(controlName + " is Unchecked"); } else if (checkboxstate == "uncheck") { Report.Success(controlName + " Check box is Unchecked"); } } }
/// <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); } }
//********************************************************************** /// <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 SetState(this Ranorex.CheckBox checkBox, bool?state) { if (state == true) { checkBox.Check(); } else { checkBox.Uncheck(); } }
public static void ClickThis(this Ranorex.CheckBox item) { try { item.Click(); Sleep(); } catch (Exception ex) { throw new Exception("Checkbox Click Failed : " + ex.Message); } }
public static void Fetching_WebUpdates_Options(string Buildname) { Buildname = Buildname.Replace(" ", string.Empty); Buildname = Buildname.ToLower(); WebElements_Count.Clear(); WebElements_options.Clear(); DefaultValues_WebElements.Clear(); int checkboxCount = 0; int comboboxCount = 0; int checkboxCount2 = 0; Ranorex.Container WebCon = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container[@automationid='PART_ExtendedScrollViewer']/container"; IList <UIAutomation> WebCon_List = WebCon.FindChildren <UIAutomation>(); for (int i = 0; i <= WebCon_List.Count - 1; i++) { if (WebCon_List[i].ControlType == "CheckBox" || WebCon_List[i].ControlType == "ComboBox") { WebElements_Count.Add(WebCon_List[i].ControlType); } } for (int k = 0; k <= WebElements_Count.Count - 1; k++) { if (WebElements_Count[k] == "CheckBox") { int c3 = checkboxCount2 + 1; Ranorex.CheckBox checkboxData = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container/container/checkbox[" + c3 + "]"; // WebElements_options.Add(checkboxData); string Checkbox_text = checkboxData.Text; if (Checkbox_text == "Check for updates on a scheduled interval") { // WebElements_options.Add("Check Updates Interval"); WebElements_options.Add("Check For Updates Automatically"); } else if (Checkbox_text == "Always download updates when available") { WebElements_options.Add("Download updates automatically"); } else { WebElements_options.Add(Checkbox_text); } checkboxCount2++; } else if (WebElements_Count[k] == "ComboBox") { if (Buildname.Contains("smartfit") || Buildname.Contains("audigy")) { WebElements_options.Add("Check Updates Interval"); } else if (Buildname.Contains("solusmax")) { WebElements_options.Add("Week"); } // WebElements_options.Add("Check Updates Interval"); } } for (int j = 0; j <= WebElements_Count.Count - 1; j++) { if (WebElements_Count[j] == "CheckBox") { int c1 = checkboxCount + 1; Ranorex.CheckBox txtChecked = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container/container/checkbox[" + c1 + "]"; if (txtChecked.Checked == true) { DefaultValues_WebElements.Add("Yes"); } else { DefaultValues_WebElements.Add("No"); } checkboxCount++; } else if (WebElements_Count[j] == "ComboBox") { int c2 = comboboxCount + 1; Ranorex.ComboBox txtCombText = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container/container/combobox[" + c2 + "]"; DefaultValues_WebElements.Add(txtCombText.Text); comboboxCount++; } } }
public static void Fetching_Machine_Preference() { int _ComboBoxCount = 0; FSW_MachinePreference_List.Clear(); DefaultValues_MachinePreference_List.Clear(); Ranorex.Container Container_Machine_Prefernces = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container[@automationid='PART_ExtendedScrollViewer']"; IList <UIAutomation> Machine_Preferncest_list = Container_Machine_Prefernces.FindChildren <UIAutomation>(); for (int i = 0; i <= Machine_Preferncest_list.Count - 4; i++) { string name = Machine_Preferncest_list[i].Name; if (name != null) { // fswprefernce=fswprefernce.Replace(" ",string.Empty); //name=name.Replace(":",string.Empty); name = name.Replace(":", string.Empty); if (!(name == null || name == "Test" || name == "Parameters" || name == "Yes")) { // FSW_MachinePreference_List.Add(Machine_Preferncest_list[i].Name); if (name == "Pediatric Default Target Rule") { FSW_MachinePreference_List.Add("Default Pediatric Fitting Rule"); } else if (name == "Default Experience") { FSW_MachinePreference_List.Add("Default Experience Level"); } else if (name == "Show GN Online Services System Tray Icon") { FSW_MachinePreference_List.Add("System Tray Visibility"); } else if (name == "Programming Interface") { FSW_MachinePreference_List.Add("Default Programming Interface"); } else { FSW_MachinePreference_List.Add(name); } } } } ElementList_Count.Clear(); for (int j = 0; j <= Machine_Preferncest_list.Count - 4; j++) { string elementname = Machine_Preferncest_list[j].ControlType; if (elementname == "ComboBox" || elementname == "CheckBox" || elementname == "Button") { if (elementname == "Button") { if (Machine_Preferncest_list[j].Name == "Yes") { ElementList_Count.Add(elementname); } } else { ElementList_Count.Add(elementname); } } } for (int k = 0; k <= ElementList_Count.Count - 1; k++) { if (ElementList_Count[k] == "ComboBox") { int m = _ComboBoxCount + 1; // int m= Ranorex.ComboBox Comb_text = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container/combobox[" + m + "]"; string defvalue = Comb_text.Text; if (defvalue == "DSLv5 - Pediatric") { DefaultValues_MachinePreference_List.Add("DSLv5b - Pediatric"); } else { DefaultValues_MachinePreference_List.Add(defvalue); } _ComboBoxCount++; } else if (ElementList_Count[k] == "CheckBox" || ElementList_Count[k] == "Button") { if (ElementList_Count[k] == "CheckBox") { Ranorex.CheckBox checkedCondition = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container/checkbox[@automationid='PART_UsePinCodeCheckBox']"; if (checkedCondition.Checked == true) { DefaultValues_MachinePreference_List.Add("Yes"); } else { DefaultValues_MachinePreference_List.Add("No"); } } else if (ElementList_Count[k] == "Button") { Ranorex.Button btnpressedCondition = "/form[@classname='Window' and @orientation='None' and @processname='SmartFit' or @processname='SolusMax']/container/button[@automationid='PART_SegmentedToggleButton']"; if (btnpressedCondition.Pressed == true) { DefaultValues_MachinePreference_List.Add("Yes"); } else { DefaultValues_MachinePreference_List.Add("No"); } } } } }