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 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 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 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 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 int GetListCount(Ranorex.Adapter listItems) { var lstData = listItems.As <Ranorex.List>(); Report.Success("Count of List is returned"); return(lstData.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 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 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 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 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 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 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 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 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 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 checkImportedData(Ranorex.Adapter adapter, string expFile) { string actualPad = adapter.As <Ranorex.Text>().TextValue.Replace(" ", "").Replace("\r\n", ""); string pathToExpect = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"ExpectedRunDetails\Measurements", expFile); string expectedPad = File.ReadAllText(pathToExpect).Replace(" ", "").Replace("\r\n", ""); Report.Info("Actual pad Value:\r\n" + actualPad); if (actualPad.Equals(expectedPad)) { Report.Info("Expected pad Value:\r\n" + expectedPad); Report.Success("Data is as imported into Measurements section."); } else if (actualPad.Equals(expectedPad.Replace(".0000", ""))) { Report.Info("Expected pad Value:\r\n" + expectedPad.Replace(".0000", "")); Report.Success("Data is as imported into Measurements section."); } else { Report.Info("Expected pad Value:\r\n" + expectedPad); Report.Failure("Data is not as imported into Measurements section."); } }
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)); } }
public int GetRowNumberFromTable(Ranorex.Adapter tbldata, string data, string tblName) { int i, j, k = 0; int rowNumber = 0; var tadapter = tbldata.As <Ranorex.Table>(); for (i = 0; i < tadapter.Rows.Count; i++) { for (j = 0; j < tadapter.Rows[i].Cells.Count; j++) { if (tadapter.Rows[i].Cells[j].As <Ranorex.Cell>().Text.Contains(data)) { Report.Success(String.Format("Value \"{0}\" Found in Row {1} as expected in \"{2}\"", data, j, tblName)); rowNumber = i; return(rowNumber); } } } if (k == 0) { Report.Failure(String.Format("Value \"{0}\" not found expected in \"{2}\"", data, tblName)); } return(rowNumber); }
public void compareWholeTable(Ranorex.Adapter repoItem, string filename_ReferenceTableSnapshot, string customLogMessageOverall, string customLogMessageDetail) { // check if snapshot file exists const string fileNotExists = "The given file does not exist: {0}"; if (!System.IO.File.Exists(filename_ReferenceTableSnapshot)) { throw new Ranorex.ValidationException(string.Format(fileNotExists, filename_ReferenceTableSnapshot)); } ElementSnapshot snap = null; try { snap = Ranorex.Core.ElementSnapshot.CreateFromFile(filename_ReferenceTableSnapshot); // ElementSnapshot.CreateFromFile is available starting with Ranorex 5.4.2 } catch { throw new Ranorex.ValidationException("Snapshot could not be loaded from file"); } // restore table from snapshot Ranorex.Table refTable; try { refTable = snap.Element; } catch { throw new Ranorex.ValidationException("Table could not be created from snapshot"); } var tableAdapter = repoItem.As <Ranorex.Table>(); if (tableAdapter == null) { throw new Ranorex.ValidationException("Repo-item could not be accessed"); } // check if rowcount is identical if (tableAdapter.Rows.Count != refTable.Rows.Count) { throw new Ranorex.ValidationException(String.Format("Tables do not have same number of rows ({0} vs. {1})", tableAdapter.Rows.Count, refTable.Rows.Count)); } // run through table-rows for (int iRow = 0; iRow <= tableAdapter.Rows.Count - 1; iRow++) { int cellCountCur = tableAdapter.Rows[iRow].Cells.Count; int cellCountRef = refTable.Rows[iRow].Cells.Count; // check if number of cells is identical in current row if (cellCountCur != cellCountRef) { throw new Ranorex.ValidationException(String.Format("Table-Rows do not have same number of cells ({0} vs. {1})", cellCountCur, cellCountRef)); } // run through cells in current row for (int iCol = 0; iCol <= cellCountCur - 1; iCol++) { string aCurText = tableAdapter.Rows[iRow].Cells[iCol].As <Ranorex.Cell>().Text; string aRefText = refTable.Rows[iRow].Cells[iCol].As <Ranorex.Cell>().Text; string validationMessage = string.Empty; if (string.IsNullOrEmpty(customLogMessageDetail)) { validationMessage = String.Format("Comparing content of cell ({2}/{3}) (found:'{0}', expected: '{1}')", aCurText, aRefText, iRow, iCol); } else { validationMessage = customLogMessageDetail; } // validate whether current text and expected text are identical Ranorex.Validate.AreEqual(aCurText, aRefText, validationMessage); } } // Log overall success if (string.IsNullOrEmpty(customLogMessageOverall)) { customLogMessageOverall = "Successfully completed content-validation of table with provided snapshot of table (reference)"; } Ranorex.Report.Log(ReportLevel.Success, customLogMessageOverall); }
public int GetTableRowCount(Ranorex.Adapter tbldata, string tblName) { var tadapter = tbldata.As <Ranorex.Table>(); return(tadapter.Rows.Count); }