public void VerifyListItemDropdown(Ranorex.Adapter dpdwnData, string[] itemValues, string dpdwnName) { int k = 0; dpdwnData.Click(); var cmbbxData = dpdwnData.As <Ranorex.ComboBox>(); //cmbbxData.Click(); IList <Ranorex.ListItem> listitems = cmbbxData.Items; foreach (string item in itemValues) { foreach (Ranorex.ListItem val in listitems) { // Report.Info(val.Text.ToString()); if (val.Text.Equals(item)) { //item.Click(); Report.Success(String.Format("Value \"{0}\" Present as expected in \"{1}\" dropdown", item, dpdwnName)); k++; //break; } } } // Report.Info(k.ToString()); // Report.Info(itemValues.Length.ToString()); if (k == itemValues.Length) { Report.Success(String.Format("{0} Values present for selection in \"{1}\" dropdown as expected", itemValues.Length, dpdwnName)); } else { Report.Failure(String.Format("{0} Values not present for selection in \"{1}\" dropdown as expected", itemValues.Length, dpdwnName)); } dpdwnData.Click(); }
public int GetListCount(Ranorex.Adapter listItems) { var lstData = listItems.As <Ranorex.List>(); Report.Success("Count of List is returned"); return(lstData.Items.Count); }
public void VerifyDataExistsInTable(Ranorex.Adapter tbldata, string[] data, string tblName) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); string d = ""; foreach (var myrow in tadapter.Rows) { foreach (var cell in myrow.Cells) { foreach (string txt in data) { if (cell.Text.Contains(txt)) { Report.Success(String.Format("Value \"{0}\" Present as expected in \"{1}\"", txt, tblName)); k++; d = txt; break; } } } } if (k == 0) { Report.Failure(String.Format("Value \"{0}\" not present in \"{1}\"", d, tblName)); } }
public void MultipleSelection(Ranorex.Adapter item, string[] data) { int i, j, k = 0; var tadapter = item.As <Ranorex.Table>(); for (i = 0; i < tadapter.Rows.Count; i++) { if (k >= data.Length) { break; } for (j = 0; j < tadapter.Rows[i].Cells.Count; j++) { if (tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text.Equals(data[k])) { tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Focus(); tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Click(); Keyboard.Press("{LControlKey down}"); k++; // i=0; break; } } } Keyboard.Press("{LControlKey up}"); }
public void VerifyCorrespondingDataExistsInTable(Ranorex.Adapter tbldata, string data, string[] correspondData, string tblName) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { for (int j = 0; j < tadapter.Rows[i].Cells.Count; j++) { if (tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text.Contains(data)) { for (int x = 0; x < tadapter.Rows[i].Cells.Count; x++) { for (int m = 0; m < correspondData.Length; m++) { if (tadapter.Rows[i].Cells[x].As <Ranorex.Cell>().Text.Contains(correspondData[m])) { Report.Success(String.Format("Corresponding Value \"{0}\" Present as expected for {1} in \"{2}\"", correspondData[m], data, tblName)); k++; //break; } } } } } } if (k == 0) { Report.Failure(String.Format("Corresponding Value \"{0}\" not present as expected for {1} in \"{2}\"", correspondData.ToString(), data, tblName)); } }
public bool ValidateDatainTable(Ranorex.Adapter tbldata, string data, string tblName) { int k = 0; bool status = false; var tadapter = tbldata.As <Ranorex.Table>(); foreach (var myrow in tadapter.Rows) { foreach (var cell in myrow.Cells) { if (cell.Text.Contains(data)) { //Report.Success(String.Format("Value \"{0}\" Present as expected in \"{1}\"",data,tblName)); k++; status = true; break; } } if (k > 0) { break; } } if (k == 0) { //Report.Failure(String.Format("Value \"{0}\" not present in \"{1}\"",data,tblName)); status = false; } return(status); }
public string RetrieveCurrentSelectionFromTable(Ranorex.Adapter tbldata, string colname, string tblName) { int m = 0; string details = ""; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { for (int j = 0; j < tadapter.Rows[i].Cells.Count; j++) { if (tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text.Equals(colname)) { for (int k = i + 1; k < tadapter.Rows.Count; k++) { details += tadapter.Rows[k].Cells[j].As <Ranorex.Cell>().Text; m++; } } } if (m > 0) { break; } } if (m == 0) { Report.Failure(String.Format("Data \"{0}\" not present for retrieval in \"{1}\"", colname, tblName)); } return(details); }
public void CheckMatrixNamesAdapter(Ranorex.Adapter adapter, int expCount, int loopCount) { adapter.Click(); adapter.Click(); Delay.Seconds(1); var items = adapter.Children[3].Children[0].Children[0].Children; if (items.Count == expCount) { var actualItem = ""; for (int i = 0; i < loopCount; i++) { actualItem = items[i].Element.GetAttributeValueText("Text"); if (!actualItem.Equals(_expectedNames[i])) { Report.Info("Index: " + i); Report.Failure(String.Format("Matrix combobox item with index: {0} does not equal to expected value. Actual: {1}, Expected: {2}", i, actualItem, _expectedNames[i])); } else { Report.Success(String.Format("Matrix combobox item with index: {0} equals to expected value. Actual: {1}, Expected: {2}", i, actualItem, _expectedNames[i])); } } } else { Report.Failure(String.Format("Matrix Selection combobox contains {0} items, expected: 26", items.Count)); } }
public void SelectItemDropdown(Ranorex.Adapter dpdwnData, string itemValue, string dpdwnName) { int k = 0; dpdwnData.Click(); var cmbbxData = dpdwnData.As <Ranorex.ComboBox>(); //cmbbxData.Click(); IList <Ranorex.ListItem> listitems = cmbbxData.Items; Delay.Milliseconds(500); foreach (Ranorex.ListItem item in listitems) { if (item.Text.Equals(itemValue)) { item.Click(); Report.Success(String.Format("Value \"{0}\" Selected as expected in \"{1}\" dropdown", itemValue, dpdwnName)); k++; break; } } if (k == 0) { Report.Failure(String.Format("Value \"{0}\" not present for selection in \"{1}\" dropdown", itemValue, dpdwnName)); } }
public void InputLimit(string limit, Ranorex.Adapter adapter) { adapter.Click(); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence '{LControlKey down}{Akey}{LControlKey up}'."); Keyboard.Press("{LControlKey down}{Akey}{LControlKey up}"); Keyboard.Press(limit); }
public int getEmailCountFromSelectedFolder(Ranorex.Adapter item) { //IList<Ranorex.Unknown> elements=item.Find<Ranorex.Unknown>("/element[@classname='LeafRow']"); IList <Ranorex.Unknown> elements = item.FindChildren <Ranorex.Unknown>(); Report.Info(elements.Count.ToString()); return(elements.Count); }
public void openProperties(Ranorex.Adapter adapter) { if (!adapter.Visible) { repo.ProtocolAnalysisDesktop.Properties.Click(); } else { Report.Screenshot(); } }
public void openProperties(Ranorex.Adapter adapter) { if (!adapter.Visible) { repo.ResultsAnalysis.Property.Click(); } else { Report.Screenshot(); } }
public int GetIndex(Ranorex.Adapter listItems, string data) { var lstData = listItems.As <Ranorex.List>(); for (int i = 0; i < lstData.Items.Count; i++) { if (lstData.Items[i].Text.Contains(data)) { Report.Success(String.Format("Item found for the text - {0}", data)); return(i); } } Report.Failure(String.Format("Item not found for the text - {0}", data)); return(0); }
public void PrintTableData(Ranorex.Adapter tbldata, string tblName) { string rowData = ""; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { rowData = ""; for (int j = 0; j < tadapter.Rows[i].Cells.Count; j++) { rowData += tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text + "--"; } Report.Success(String.Format("Row {0} Data is {1}: ", i + 1, rowData)); } }
public void VerifyListItemsInDropdown(Ranorex.Adapter listItems, string[] data, string dpdwnName) { var lstData = listItems.As <Ranorex.List>(); foreach (string dat in data) { foreach (Ranorex.ListItem item in lstData.Items) { if (item.Text.Contains(dat)) { Report.Success(String.Format("ListItem \"{0}\" is present in \"{1}\" dropdown as expected", dat, dpdwnName)); } } } }
public string RetrieveCurrentSelectionFromTable(Ranorex.Adapter item) { string data = ""; var tadapter = item.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count - 1; i++) { data += tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().Text + ","; } data += tadapter.Rows[tadapter.Rows.Count - 1].Cells[0].As <Ranorex.Cell>().Text; if (data == "") { Report.Failure(String.Format("Current Selection is empty in \"{0}\"", item)); } return(data); }
public void MultiplePeopleSelection(Ranorex.Adapter item, int noOfItems) { int i = 0; string down = ""; var tadapter = item.As <Ranorex.Table>(); if (tadapter.Rows.Count > 1) { i = 1; } tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().Click(); for (int k = 0; k < noOfItems; k++) { down += "{Down}"; } Keyboard.Press("{LShiftKey down}" + down + "{LShiftKey up}"); Report.Success("Multiple Selection performed for People"); }
public void ListArticles(Ranorex.Adapter postsContainer) { var element = postsContainer.GetPath().ToString(); postsContainer.EnsureVisible(); //IList<Ranorex.ArticleTag> IArticles = postsContainer.As<Ranorex.DivTag>().FindDescendants<Ranorex.ArticleTag>(); IList <Ranorex.ArticleTag> IArticles = Host.Local.Find <Ranorex.ArticleTag>(element + "//article", 5000); Ranorex.Report.Log(ReportLevel.Info, "There are " + IArticles.Count + " on this page"); // Collect article headers foreach (Ranorex.ArticleTag articles in IArticles) { string articleheader = articles.FindDescendant <Ranorex.ATag>().InnerText; Ranorex.Report.Info("article", articleheader); } }
public void VerifyListItemsInDropdown(Ranorex.Adapter listItems, string data, string dpdwnName) { int k = 0; var lstData = listItems.As <Ranorex.List>(); foreach (Ranorex.ListItem item in lstData.Items) { if (item.Text.Contains(data)) { Report.Success(String.Format("ListItem \"{0}\" is present in \"{1}\" dropdown as expected", data, dpdwnName)); k++; } } if (k == 0) { Report.Failure(String.Format("ListItem \"{0}\" not present for in \"{1}\" dropdown", data, dpdwnName)); } }
public void SelectItemFromTableDblClick(Ranorex.Adapter tbldata, string itemValue) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { if (tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().Text.Contains(itemValue)) { tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().DoubleClick(); Report.Success(String.Format("Value \"{0}\" Selected as expected", itemValue)); k++; break; } } if (k == 0) { Report.Info(String.Format("Value \"{0}\" not present for selection/Value already selected ", itemValue)); } }
public string RetrieveCurrentSelectionFromTable(Ranorex.Adapter tbldata, int colnumber, string tblName) { int m = 0; string details = ""; string result = ""; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { details += tadapter.Rows[i].Cells[colnumber].As <Ranorex.Cell>().Text + "~"; m++; } result = details.Substring(0, details.Length - 1); if (m == 0) { Report.Failure(String.Format("Column index \"{0}\" values not present for retrieval in \"{1}\"", colnumber, tblName)); } return(result); }
public void SelectItemFromTableDblClick(Ranorex.Adapter tbldata, string data, string tblName) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { for (int j = 0; j < tadapter.Rows[i].Cells.Count; j++) { if (tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text.Contains(data)) { if (j + 1 < tadapter.Rows[i].Cells.Count) { tadapter.Rows[i].Cells[j + 1].As <Ranorex.Cell>().Focus(); //tadapter.Rows[i].Cells[j+1].As<Ranorex.Cell>().MoveTo(); tadapter.Rows[i].Cells[j + 1].As <Ranorex.Cell>().DoubleClick(); Report.Success(String.Format("Value \"{0}\" Selected as expected in \"{1}\"", data, tblName)); k++; break; } else { tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Focus(); //tadapter.Rows[i].Cells[j].As<Ranorex.Cell>().MoveTo(); tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().DoubleClick(); Report.Success(String.Format("Value \"{0}\" Selected as expected in \"{1}\"", data, tblName)); k++; break; } } } if (k > 0) { break; } } if (k == 0) { Report.Failure(String.Format("Value \"{0}\" not present for selection in \"{1}\"", data, tblName)); } }
public void SelectItemDropdown(Ranorex.Adapter tbldata, string itemValue) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { //Report.Info(tadapter.Rows[i].Cells[0].As<Ranorex.Cell>().Text.ToString()); if (tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().Text.Contains(itemValue)) { tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().Click(); Report.Success(String.Format("Value \"{0}\" Selected as expected", itemValue)); k++; break; } } if (k == 0) { Report.Failure(String.Format("Value \"{0}\" not present for selection ", itemValue)); } }
public void CaptureArticles(Ranorex.Adapter postsContainer) { //Get the RXPath of the passed OR element var element = postsContainer.GetPath().ToString(); int x = 1; //Incremented at the end of the following do loop. If x>1 clcik Next int rowcount = 1; //Keeps tract of rows to be written to Excel. Start at 1. //Loop to capture articles do { //For first do loop iteration x=1, so we will not click "Next" if (x > 1) { repo.EdgewordsTrainingAutomatedSoftware.Next.Click(); repo.EdgewordsTrainingAutomatedSoftware.Self.WaitForDocumentLoaded(); } postsContainer.EnsureVisible(); //IList<Ranorex.ArticleTag> IArticles = postsContainer.As<Ranorex.DivTag>().FindDescendants<Ranorex.ArticleTag>(); //Generate list of articles inside passed OR item. The above approach failed (presumably the element becomes //stale after navigating to the next set of results IList <Ranorex.ArticleTag> IArticles = Host.Local.Find <Ranorex.ArticleTag>(element + "//article", 5000); Ranorex.Report.Log(ReportLevel.Info, "There are " + IArticles.Count + " on this page"); // Collect article headers foreach (Ranorex.ArticleTag articles in IArticles) { string articleheader = articles.FindDescendant <Ranorex.ATag>().InnerText; Ranorex.Report.Info("article", articleheader); writedata(articleheader, rowcount); //Call helper method to write to Excel rowcount++; } x++; //Increment X so on next loop the "Next" button is clicked }while(repo.EdgewordsTrainingAutomatedSoftware.NextInfo.Exists(3000)); // Only loop if there is a "Next" button }
//========================================================================================================================= // This function will not work without changing the connection string portion //========================================================================================================================= public void compareDataFromDBA2B(Ranorex.Adapter argument1, string argument2) { //This has to be modified to the correct location of the DB's OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\aahsan\Desktop\DBExample\DBConnectorExample\DatabaseA.accdb;"); //This has to be modified to the correct location of the DB's OleDbConnection con2 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\aahsan\Desktop\DBExample\DBConnectorExample\DatabaseB.accdb;"); OleDbCommand cmd = new OleDbCommand("select Casenumber From Table1", con); OleDbCommand cmd2 = new OleDbCommand("select Casenumber From Table1", con2); con.Open(); con2.Open(); OleDbDataReader dr = cmd.ExecuteReader(); OleDbDataReader dr2 = cmd2.ExecuteReader(); int row = 1; while (dr.Read()) { while (dr2.Read()) { if (dr["CaseNUmber"].ToString() == dr2["CaseNUmber"].ToString()) { Report.Info("Match Found at Row: " + row + "." + " The data in DB A " + (dr["CaseNUmber"].ToString()) + " matches the data in DB B " + (dr2["CaseNUmber"].ToString())); varRow1 = dr["CaseNUmber"].ToString(); TestCase.Current.Parameters["GBLRow1"] = varRow1; } else { Report.Info("This data in DB A " + (dr["CaseNUmber"].ToString()) + " doese not match the data in DB B " + (dr2["CaseNUmber"].ToString()) + " in Row : " + row); } row++; } } con.Close(); con2.Close(); }
public string getWebTableDetails(Ranorex.Adapter table) { var tadapter = table.As <Ranorex.TableTag>(); string result = ""; IList <Ranorex.TrTag> myRows = tadapter.FindDescendants <Ranorex.TrTag>(); // print out count of rows stored in a list // Report.Log(ReportLevel.Info,"Row Count: ", myRows.Count.ToString()); for (int i = 0; i < myRows.Count; i++) // get all columns in specified row and store them in a list { IList <Ranorex.TdTag> myCols = myRows[i].FindDescendants <Ranorex.TdTag>(); // Report.Log(ReportLevel.Info,"Column Count: ", myCols.Count.ToString()); for (int j = 0; j < myCols.Count; j++) { result += myCols[j].InnerText + "~"; } result += "|"; } // print out count of columns stored in the list return(result); }
public void SelectItemFromTableDblClick(Ranorex.Adapter tbldata, int rowno) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); var rowcount = tadapter.Rows.Count; //Report.Info(rowcount); for (int i = 0; i < rowcount; i++) { if (tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().RowIndex == rowno) { tadapter.Rows[i].Cells[0].As <Ranorex.Cell>().DoubleClick(); Report.Success(String.Format("Value Selected as expected")); k++; break; } } if (k == 0) { Report.Info(String.Format("Value not present for selection/Value already selected ")); } }
public static void WebToExcel(Ranorex.Adapter htmlTable, String path) { // the false parameter means not to append but overwrite the file if it exists: TextWriter textWriter = new StreamWriter(path, false, System.Text.Encoding.UTF8); // Get the Web Table Rows (have to convert the repo item to web table tag) IList <Ranorex.TrTag> IRows = htmlTable.As <Ranorex.TableTag>().FindDescendants <Ranorex.TrTag>(); // Loop through each row and get the cells foreach (Ranorex.TrTag theRow in IRows) { // Get the Cells in Each Row IList <Ranorex.TdTag> ICells = theRow.FindDescendants <Ranorex.TdTag>(); // loop through each cell in the row String StrCSV = ""; foreach (Ranorex.TdTag theCell in ICells) { StrCSV += theCell.GetInnerHtml() + ","; } textWriter.WriteLine(StrCSV); } textWriter.Close(); }
public void OpenContextMenuItemFromTable(Ranorex.Adapter tbldata, string data, string tblName) { int k = 0; var tadapter = tbldata.As <Ranorex.Table>(); for (int i = 0; i < tadapter.Rows.Count; i++) { for (int j = 0; j < tadapter.Rows[i].Cells.Count; j++) { if (tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text.Contains(data)) { if (j < tadapter.Columns.Count) { tadapter.Rows[i].Cells[j + 1].As <Ranorex.Cell>().Focus(); Mouse.Click(tadapter.Rows[i].Cells[j + 1].As <Ranorex.Cell>(), WinForms.MouseButtons.Right); } else { tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Focus(); Mouse.Click(tadapter.Rows[i].Cells[j].As <Ranorex.Cell>(), WinForms.MouseButtons.Right); } Report.Success(String.Format("Value \"{0}\" Context Clicked as expected in \"{1}\"", data, tblName)); k++; break; } } if (k > 0) { break; } } if (k == 0) { Report.Failure(String.Format("Value \"{0}\" not present for selection in \"{1}\"", data, tblName)); } }