public static void AcknowledgeAllergy(string ReasonAcknowledge, RepoItemInfo AckButton, RepoItemInfo SaveButton) { if (AckButton.Exists(3000)) { Report.Log(ReportLevel.Info, "AcknowledgedButton exist"); //if the Acknowledge Button displays, click on Acknowledge button Delay.Milliseconds(500); Report.Log(ReportLevel.Info, "Click on AcknowledgedButton"); AckButton.FindAdapter <CheckBox>().Click(); Delay.Milliseconds(100); // enter reason detail repo.MainWindow.Modalities.ReasonForAcknowledgeAllergy.Reason.Click(); Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Enter on Acknowledged reason"); Keyboard.Press(ReasonAcknowledge); Delay.Milliseconds(100); // Click on Save Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Click on Save"); SaveButton.FindAdapter <Text>().Click(); Delay.Milliseconds(1000); } else { Report.Log(ReportLevel.Info, "No allergy. AcknowledgedButton does not exist"); } }
public static void PressKeyExist(RepoItemInfo objInfo, string strKeys) { if (objInfo.Exists(3000)) { objInfo.FindAdapter <Unknown>().PressKeys(strKeys); } }
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); } }
//TODO: + check if visible, + timeout // ab ins common // rename to IsRepoItemVisible //TODO: WaitForItemVisible(RepoItemInfo item); /// <summary> /// Checks and waits if a page exists /// </summary> /// <param name="item">The item to validate and wait for</param> /// <returns>True if the page exists</returns> public bool WaitForItemVisible(RepoItemInfo item) { try { Stopwatch watch = new Stopwatch(); watch.Start(); while (watch.ElapsedMilliseconds < 10000) { if (watch.ElapsedMilliseconds >= 10000) { return(false); } if (item.Exists()) { watch.Stop(); return(true); } } //check if item is visible } catch (RanorexException) { Report.Failure("Page was not shown after ten seconds. "); return(false); } return(true); }
//********************************************************************** /// <summary> /// Open excel file, verify content contains or not contains given string. /// </summary> public static void VerifyExcelfileValues(LxScriptItem item) { string strPath = item.getArgText(); string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1, strPath.Length - strPath.LastIndexOf("/") - 1); string mark = item.getArg3Text(); // flag=true, contains; flag=false, not contains. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "excel.exe"; startInfo.Arguments = " " + strPath; System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo); RepoItemInfo targetCellInfo = new RepoItemInfo(repo.ExternalApp.FormExcel.TableEntityInfo.ParentFolder, "variableCell", repo.ExternalApp.FormExcel.TableEntityInfo.Path + "/row/cell[@text='" + item.getArg2Text() + "']", 10000, null, System.Guid.NewGuid().ToString()); Delay.Milliseconds(6000); bool bExists = targetCellInfo.Exists(); process.Kill(); if (mark.Equals("True")) { Validate.AreEqual(bExists, true); } else { Validate.AreEqual(bExists, false); } }
public void ConfirmOverwrite(RepoItemInfo buttonInfo) { if (buttonInfo.Exists()) { Report.Log(ReportLevel.Info, "Mouse", "(Optional Action)\r\nMouse Left Click item 'buttonInfo' at Center.", buttonInfo); buttonInfo.FindAdapter <Button>().Click(); } }
public void DoNotSaveIfAsked(RepoItemInfo buttonInfo) { if (buttonInfo.Exists(Duration.FromMilliseconds(1000))) { Report.Log(ReportLevel.Info, "Mouse", "(Optional Action)\r\nMouse Left Click item 'buttonInfo' at Center.", buttonInfo); buttonInfo.FindAdapter <Button>().Click(); } }
public void Mouse_Click_ButtonRun(RepoItemInfo buttonInfo) { if (buttonInfo.Exists(5000)) { Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'buttonInfo' at Center.", buttonInfo); buttonInfo.FindAdapter <Button>().Click(); } }
//********************************************************************** /// <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 Validate_CreatingARanorexSnapshot(RepoItemInfo h1tagInfo) { if (h1tagInfo.Exists(5000)) { Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (InnerText='Creating a Ranorex snapshot') on item 'h1tagInfo'.", h1tagInfo); Validate.AttributeEqual(h1tagInfo, "InnerText", "Creating a Ranorex snapshot"); } else { Report.Log(ReportLevel.Info, "Validation Failed"); } }
public void Mouse_Click_AllergiesNo(RepoItemInfo rawtextInfo) { if (rawtextInfo.Exists(5000)) { Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'rawtextInfo' at Center.", rawtextInfo); rawtextInfo.FindAdapter <RawText>().Click(); } else { Ranorex.Report.Info("Patient Allergies already set"); } }
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()); } } }
public void Scroll(RepoItemInfo scrollbarInfo, string Directon, RepoItemInfo searchedItemInfo) { int count = 0; if (scrollbarInfo.Exists(5000)) { scrollbarInfo.FindAdapter <ScrollBar>().Click(); while (searchedItemInfo.Exists(3000) != true && count != 5) { switch (Directon) { case "up": Keyboard.Press("{PageUp}"); break; case "down": Keyboard.Press("{PageDown}"); break; } count = count + 1; } } }
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); } } }
//********************************************************************** /// <summary> /// Verify the comoponet like List, Table and Tree not contains given items. /// </summary> public static void VerifyNotContains(LxScriptItem item) { object objComponet = item.getComponent(); RepoItemInfo objComponetInfo = item.getComponentInfo(); Type objType = objComponet.GetType(); if (objType.Name.ToString() == "List") { RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem", objComponetInfo.Path + "/listitem[@accessiblename='" + item.getArgText() + "']", 10000, null, System.Guid.NewGuid().ToString()); Validate.AreEqual(targetListItemInfo.Exists(), false); } 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()); Validate.AreEqual(targetCellInfo.Exists(), false); } 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()); Validate.AreEqual(targetTreeItemInfo.Exists(), false); } }
//********************************************************************** /// <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> /// Open excel file, verify content contains or not contains given string. /// </summary> public static void VerifyExcelfileValues(LxScriptItem item) { string strPath = item.getArgText(); string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1,strPath.Length - strPath.LastIndexOf("/") -1); string mark = item.getArg3Text(); // flag=true, contains; flag=false, not contains. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "excel.exe"; startInfo.Arguments = " " + strPath; System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo); RepoItemInfo targetCellInfo = new RepoItemInfo(repo.ExternalApp.FormExcel.TableEntityInfo.ParentFolder, "variableCell", repo.ExternalApp.FormExcel.TableEntityInfo.Path + "/row/cell[@text='"+ item.getArg2Text() +"']", 10000, null, System.Guid.NewGuid().ToString()); Delay.Milliseconds(6000); bool bExists = targetCellInfo.Exists(); process.Kill(); if(mark.Equals("True")) Validate.AreEqual(bExists,true); else Validate.AreEqual(bExists,false); }
//********************************************************************** /// <summary> /// Verify the comoponet like List, Table and Tree not contains given items. /// </summary> public static void VerifyNotContains(LxScriptItem item) { object objComponet = item.getComponent(); RepoItemInfo objComponetInfo = item.getComponentInfo(); Type objType = objComponet.GetType(); if(objType.Name.ToString() == "List") { RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem", objComponetInfo.Path + "/listitem[@accessiblename='"+ item.getArgText() +"']", 10000, null, System.Guid.NewGuid().ToString()); Validate.AreEqual(targetListItemInfo.Exists(),false); } 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()); Validate.AreEqual(targetCellInfo.Exists(),false); } 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()); Validate.AreEqual(targetTreeItemInfo.Exists(),false); } }
public void SelectMedication(string BlockName, string Medication, string FormName, string Mode, string Weight, RepoItemInfo DisclaimBox) { //==================// Select Regional Block name.Only PCEA and Regional Infusion need Block Name if (FormName == "fmPCEA" || FormName == "fmRegionalInfusion") { // Select Regional Block name Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'AddPainPrescription.RegionalBlock' at Center.", repo.AddPainPrescription.RegionalBlockInfo, new RecordItemIndex(0)); repo.AddPainPrescription.RegionalBlock.Click(); Delay.Milliseconds(200); Report.Log(ReportLevel.Info, "Keyboard", "Key 'Home' Press."); Keyboard.Press(System.Windows.Forms.Keys.Home, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Delay.Milliseconds(200); Report.Log(ReportLevel.Info, "Keyboard", "Key 'Shift+End' Press."); Keyboard.Press(System.Windows.Forms.Keys.End | System.Windows.Forms.Keys.Shift, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Delay.Milliseconds(200); Report.Log(ReportLevel.Info, "Keyboard", "Key 'Back' Press."); Keyboard.Press(System.Windows.Forms.Keys.Back, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Delay.Milliseconds(200); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence from variable '$BlockName'.", new RecordItemIndex(1)); Keyboard.Press(BlockName); Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Keyboard", "Key 'Enter' Press.", new RecordItemIndex(2)); Keyboard.Press(System.Windows.Forms.Keys.Return, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Delay.Milliseconds(0); } //============ Seelct Medication name, Mode ( for all type of pain Prescrpition)=================================== // Select Medication name Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'AddPainPrescription.Medication' at Center.", repo.AddPainPrescription.MedicationInfo, new RecordItemIndex(3)); repo.AddPainPrescription.Medication.Click(); Delay.Milliseconds(200); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence from variable '$Medication'.", new RecordItemIndex(4)); Keyboard.Press(Medication); Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Keyboard", "Key 'Enter' Press.", new RecordItemIndex(5)); Keyboard.Press(System.Windows.Forms.Keys.Return, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Delay.Milliseconds(0); // Select Mode Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'AddPainPrescription.Mode' at Center.", repo.AddPainPrescription.ModeInfo, new RecordItemIndex(6)); repo.AddPainPrescription.Mode.Click(); Delay.Milliseconds(200); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence from variable '$Mode'.", new RecordItemIndex(7)); Keyboard.Press(Mode); Delay.Milliseconds(100); Report.Log(ReportLevel.Info, "Keyboard", "Key 'Enter' Press.", new RecordItemIndex(8)); Keyboard.Press(System.Windows.Forms.Keys.Return, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Delay.Milliseconds(0); //===== Enter Toxic limitation. Only for PCEA, Resgional, and Col-Analgesia ( NOT PCA)================== if (FormName == "fmPCEA" || FormName == "fmRegionalInfusion" || FormName == "fmCoAnalgesia") { // Enter Weight Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'AddPainPrescription.Weight' at Center.", repo.AddPainPrescription.WeightInfo, new RecordItemIndex(9)); repo.AddPainPrescription.Weight.DoubleClick(); Delay.Milliseconds(200); // press "Backspace" to delete the current value Keyboard.Press(System.Windows.Forms.Keys.Back, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence from variable '$Weight'.", new RecordItemIndex(10)); Keyboard.Press(Weight); Delay.Milliseconds(5000); // Click "Acknowledge" button if (DisclaimBox.Exists(1000) && repo.AddPainPrescription.ToxicDisclaimBox.Visible) { Report.Log(ReportLevel.Info, "Mouse", "Click \"Acknowledge\" button\r\nMouse Left Click item 'AddPainPrescription.Acknowledge' at Center.", repo.AddPainPrescription.AcknowledgeInfo, new RecordItemIndex(11)); repo.AddPainPrescription.Acknowledge.Click(); Delay.Milliseconds(200); } } }