public void ValidateTextParameterTrimmedSpaces(RepoItemInfo rowInfo) { Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (AccessibleValue=$expectedTextValue) on item 'rowInfo'.", rowInfo); string currentValue = rowInfo.CreateAdapter <Row>(true).Element.GetAttributeValueText("AccessibleValue"); Validate.AreEqual(currentValue.Trim(), expectedTextValue.Trim()); }
public static void SelectComboboxItems(string strItem, RepoItemInfo Combo_Items) { if (Combo_Items.Exists()) { //create a combobox adapter ComboBox cbxItems = Combo_Items.CreateAdapter <ComboBox>(true); IList <ListItem> lstItems = cbxItems.Items; // go through all combobox items to select the answer if (lstItems != null && lstItems.Count > 0) { for (int i = 0; i < lstItems.Count; i++) { if (lstItems[i].Text == strItem) { Report.Log(ReportLevel.Info, "CLick on item name: " + strItem); lstItems[i].Selected = true; lstItems[i].Click(); Delay.Milliseconds(200); break; } } } } else { Report.Log(ReportLevel.Info, "Combobox is not exist " + strItem); } }
//********************************************************************** /// <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 void FocusAndSelectTrajectIdCell(RepoItemInfo trajectsTableInfo) { var rowToSelect = trajectsTableInfo.CreateAdapter <Table>(true). Rows.Where(rw => rw.GetAttributeValue <string>("AccessibleValue").ToString().StartsWith(trajectID)).First(); rowToSelect.Focus(); rowToSelect.Select(); signallingValue = rowToSelect.Cells[2].Text; //.ToNoGroupSeparator(); lowLimitValue = rowToSelect.Cells[3].Text; //.ToNoGroupSeparator(); }
public Ranorex.Unknown CreateAdapter(RepoItemInfo itemInfo) { try { return(itemInfo.CreateAdapter <Ranorex.Unknown>(true)); } catch (Exception e) { throw new Exception("Unable to find element with path: " + itemInfo.AbsolutePath); } }
public static void AcknowledgeAllergyBackup(RepoItemInfo AcknowledgedButtonInfo, Adapter AcknowledgeButton, RepoItemInfo ReasonBox, string ReasonAcknowledge, RepoItemInfo SaveButton) { if (AcknowledgedButtonInfo.Exists(1000)) { Report.Log(ReportLevel.Info, "AcknowledgedButton esixt" + AcknowledgeButton.GetPath().ToString()); //CheckBox chkbxItem= AcknowledgedButtonInfo.CreateAdapter<CheckBox>(true); if (AcknowledgeButton.Visible) { //click on Acknowledge button Delay.Milliseconds(200); AcknowledgeButton.Click(); Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Click on AcknowledgedButton"); // enter reason detail Text txtItem = ReasonBox.CreateAdapter <Text>(true); txtItem.Click(); Delay.Milliseconds(100); Keyboard.Press(ReasonAcknowledge); Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Enter on Acknowledged reason" + txtItem.GetPath().ToString()); // Click on Save //Text txtItemSave= SaveButton.CreateAdapter<Text>(true); Report.Log(ReportLevel.Info, "Save pathe: " + SaveButton.AbsolutePath.ToString()); SaveButton.FindAdapter <Text>().Click(); //string xpath=SaveButton.AbsolutePath.ToString(); //Ranorex.Text txtItemSave =xpath; //txtItemSave.Click(); //repo.MainWindow.Modalities.AllergyChecking.Save.Click(); //IList<Ranorex.Text> lstText = Host.Local.Find<Ranorex.Text>(SaveButton.AbsolutePath); //Text item = Host.Local.FindSingle(SaveButton.AbsolutePath); //item.Click(); //Report.Log(ReportLevel.Info,"CLick Save" + item.GetPath().ToString()); //if(lstText != null && lstText.Count>0) // lstText[0].Click(); //Report.Log(ReportLevel.Info,"CLick Save" + lstText[0].GetPath().ToString()); // Report.Log(ReportLevel.Info,"Number" + lstText.Count.ToString()); //txtItemSave.Click(); Delay.Milliseconds(1000); Report.Log(ReportLevel.Info, "CLick Save" + SaveButton.FindAdapter <Text>().GetPath().ToString()); } } }
//********************************************************************** /// <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(); */ } }
//********************************************************************** /// <summary> /// RightClick to given items in the comoponet like Container. /// </summary> public static void RightClick_Item(LxScriptItem item) { object objComponet = item.getComponent(); RepoItemInfo objComponetInfo = item.getComponentInfo(); Type objType = objComponet.GetType(); if (objType.Name.ToString() == "Container") { Ranorex.Container targetContainer = objComponetInfo.CreateAdapter <Ranorex.Container>(true); targetContainer.Click(System.Windows.Forms.MouseButtons.Right); // Mouse.ButtonDown(System.Windows.Forms.MouseButtons.Right); } }
public static void ReportFullPageScreenshot(RepoItemInfo repoItemInfo) { ProgressForm.Hide(); try { Utils.CheckArgumentNotNull(repoItemInfo, "repoItemInfo"); var webDocument = repoItemInfo.CreateAdapter <WebDocument>(false); if (webDocument == null) { Report.Error("Repository item '" + repoItemInfo.FullName + "' is not a web document. " + "Screenshot can be taken only for web documents."); return; } var screenshotFilePath = Path.GetTempFileName(); var screenshot = webDocument.CaptureFullPageScreenshot(); screenshot.Save(screenshotFilePath); Report.LogData(ReportLevel.Info, "Screenshot", screenshot); if (File.Exists(screenshotFilePath)) { try { File.Delete(screenshotFilePath); } catch { // No need to handle exception. // Temp files are deleted only to prevent piling up of unnecessary files. } } } catch (Exception ex) { Utils.ReportException(ex, libraryName); } ProgressForm.Show(); }
public void SetFMInOutAssembly(RepoItemInfo treeitemInfo, string fmShouldBeInAssembly) { var fmObjectAdapter = treeitemInfo.CreateAdapter <TreeItem>(true); string fmIsCurrentlyInAssembly = fmObjectAdapter.Children.Count == 1?"False":"True"; Report.Info("FM is currently in assembly: " + fmIsCurrentlyInAssembly); Report.Info("FM should be in assembly: " + fmShouldBeInAssembly); if (fmIsCurrentlyInAssembly == fmShouldBeInAssembly) { Report.Info("No action required"); } else { Report.Info("FM being in assembly must be changed"); fmObjectAdapter.Focus(); fmObjectAdapter.Click(System.Windows.Forms.MouseButtons.Right); repo.ContextMenu.InAssembly.Click(); } }
public static void Validate_GenericCategoryBoundaryCellAlmostEqual(RepoItemInfo cellInfo, string expectedBoundary) { Report.Log(ReportLevel.Info, "Validation", "(Optional Action)\r\nValidating AttributeEqual (AccessibleValue=$expectedBoundary) on item 'cellInfo'.", cellInfo); var currentValue = cellInfo.CreateAdapter <Cell>(true).GetAttributeValue <string>("AccessibleValue"); if (currentValue == expectedBoundary) { Validate.AttributeEqual(cellInfo, "AccessibleValue", expectedBoundary); } else { System.Globalization.CultureInfo currentCulture = CultureInfo.CurrentCulture; Report.Log(ReportLevel.Info, "Validation", "Value found: " + currentValue + " is not equal to expected value: " + expectedBoundary + "\r\nEvaluating whether they are almost (within 0.01%) equal..."); var expectedDouble = 1.0 / (Double.Parse(expectedBoundary.Substring(2, expectedBoundary.Length - 2), currentCulture)); var currentDouble = 1.0 / (Double.Parse(currentValue.Substring(2, currentValue.Length - 2), currentCulture)); var deviation = Math.Abs(100.0 * (expectedDouble - currentDouble) / expectedDouble); Report.Log(ReportLevel.Info, "Validation", "Deviation = " + deviation + " %"); Validate.IsTrue(deviation < 0.01); } }
public static void SelectReviewRound(int ReviewRound, RepoItemInfo Combo_Items) { if (Combo_Items.Exists()) { //create a combobox adapter ComboBox cbxItem = Combo_Items.CreateAdapter <ComboBox>(true); if (ReviewRound == 0) { Report.Log(ReportLevel.Info, "Select item: " + ReviewRound.ToString()); cbxItem.Items[ReviewRound].Click(); Delay.Milliseconds(200); } else { Report.Log(ReportLevel.Info, "Select item: " + (ReviewRound - 1).ToString()); //repo.MainWindow.PrintingReview.ReviewRound.SelectedItemIndex= NextReviewRound-1; //Delay.Milliseconds(200); cbxItem.Items[ReviewRound - 1].Click(); Delay.Milliseconds(200); } } }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; Ranorex.Unknown adapter = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string function = (string)arguments.GetValueOrDefault <string, object>("function"); string name = (string)arguments.GetValueOrDefault <string, object>("name"); string value = (string)arguments.GetValueOrDefault <string, object>("value"); if (function == default(string)) { throw new Exception("No validate function defined"); } if (target != default(string)) { repoItemInfo = new RepoItemInfo(repo, "CommandItem", target, 10000, null, "3529d992-a9f6-4df9-927a-3e7e1e08ca8b"); adapter = repoItemInfo.CreateAdapter <Ranorex.Unknown>(true); } if (adapter != null) { switch (function) { case "AttributeEqual": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, value); break; case "Exists": Validate.Exists(adapter); break; case "NotExists": Validate.NotExists(adapter); break; case "AttributeRegEx": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, new Regex(value)); break; case "AttributeContains": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, new Regex(Regex.Escape(value))); break; case "AttributeNotContains": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, new Regex("^((?!(" + Regex.Escape(value) + "))(.|\n))*$")); break; case "ContainsImage": break; case "CompareImage": break; } } else { } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
//********************************************************************** /// <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") { String Xpos = " "; String Ypos = " "; String sPoint ="0;0"; if((!(item.getArg3Text().Trim().Equals("")))&&(!(item.getArg4Text().Trim().Equals("")))) { Xpos = item.getArg3Text(); Ypos = item.getArg4Text(); sPoint =Xpos+";"+Ypos; } 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(sPoint); } 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(sPoint); } } }
//********************************************************************** /// <summary> /// Move mouse to given items in the comoponet like List, Table and Tree. /// </summary> public static void MoveTo(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.MoveTo(); } 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.MoveTo(); } 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.MoveTo(); } }
//********************************************************************** /// <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(); */ } }