public void AssertGridCells() { // Verify all cells using a function with Assert TestGrid.ForEachCell(cell => cell.AssertFontSize("14px")); // Get Cell by Column name TestGrid.GetCell("Firstname", 1).ValidateInnerTextIs("Mary"); // Get Cell by Cell coordinates TestGrid.GetCell(0, 1).ValidateInnerTextIs("John"); // Get a cell that is equal to an Object property TestGrid.GetCell <Employee>(cell => cell.PersonalEmail, 1).ValidateInnerTextIs("*****@*****.**"); // Get all cells that satisfy a condition using a function ElementsList <TableCell> matchingCells = TestGrid.GetCells <TableCell>(cell => cell.InnerText.StartsWith('J')); Assert.AreEqual(2, matchingCells.Count()); // Get cell with multiple-row headers TestGrid.GetCell("Email Business", 0).ValidateInnerTextIs("*****@*****.**"); // Perform actions in cell elements var firstRowEmail = TestGrid.GetRow(0).GetCell("Email Personal"); TestGrid.GetCell("Actions", 0).As <Button>().Click(); var firstRowEmailAfterDelete = TestGrid.GetRow(0).GetCell("Email Personal"); Assert.AreNotEqual(firstRowEmail, firstRowEmailAfterDelete); }
public void AssertSpecificRow() { // You can get a specific row using the GetRow method by the index of the row. var firstRow = Table.GetRow(0); // You can get the index of a given row through the Index property. Assert.AreEqual(0, firstRow.Index); // You can get the HTML through the InnerHtml property. Assert.IsTrue(firstRow.InnerHtml.Contains("</td>")); // If you only need to assert the inner HTML you can use the built-in BELLATRIX Validate methods. firstRow.ValidateInnerHtmlContains("</td>"); // There are many ways to get a specific cell through the indexer and the GetCell methods. var firstCell = Table.GetRow(0).GetCell(0); // You can again use directly the built-in BELLATRIX Validate methods. firstCell.ValidateInnerTextIs("Smith"); // You can get a cell by header name var secondCell = firstRow.GetCell("Email"); secondCell.ValidateInnerTextIs("*****@*****.**"); // You can get all row cells through the GetCells method. IEnumerable <TableCell> cells = firstRow.GetCells(); Assert.AreEqual(6, cells.Count()); // You can get the cells matching a condition. ElementsList <TableCell> matchingCells = firstRow.GetCells(cell => cell.InnerText.ToLower().Contains("smith")); Assert.AreEqual(3, matchingCells.Count()); // You can get the first cell matching a condition through the GetFirstOrDefaultCell method. var matchingCell = firstRow.GetFirstOrDefaultCell(cell => cell.InnerText.ToLower().Contains("smith")); matchingCell.ValidateInnerTextIs("Smith"); // You can convert a row to an instance of a specific class through the GetItem method. Assert.AreEqual("*****@*****.**", firstRow.GetItem <User>().Email); // You can compare a row to an instance of a specific class. // The row is internally converted to the type of the expected object. firstRow.AssertRow(_expectedUsers[0]); }
public void AssertSpecificRow() { var firstRow = TestGrid.GetRow(0); // You can get the index of a given row through the Index property. Assert.AreEqual(0, firstRow.Index); // You can get the html through the InnerHtml property. Assert.IsTrue(firstRow.InnerHtml.Contains("</td>")); firstRow.ValidateInnerHtmlContains("</td>"); // There are many ways to get a specific cell through the indexer and the GetCell methods. var firstCell = firstRow.GetCell("Order"); firstCell.As <TextField>().ValidateValueIs("0"); var secondCell = firstRow[1]; secondCell = firstRow.GetCell(1); secondCell.ValidateInnerTextIs("John"); // You can get all row cells through the GetCells method. IEnumerable <GridCell> cells = firstRow.GetCells(); Assert.AreEqual(6, cells.Count()); // You can get the cells matching a condition. Also, they will be returned as elements of a type of your choice. ElementsList <TableCell> textFields = firstRow.GetCells <TableCell>(cell => cell.InnerText.StartsWith("John") || cell.InnerText.StartsWith("john")); Assert.AreEqual(2, textFields.Count()); // You can get the first cell matching a condition through the GetFirstOrDefaultCell method. var firstInputCell = firstRow.GetFirstOrDefaultCell <TextField>(cell => cell.TagName == "input"); firstInputCell.ValidateValueIs("0"); // You can convert a row to an instance of a specific class through the GetItem method. Assert.AreEqual("John Doe", $"{firstRow.GetItem<Employee>().FirstName} {firstRow.GetItem<Employee>().LastName}"); // You can compare a row to an instance of a specific class. The row is internally converted to the type of the expected object. firstRow.AssertRow(_expectedItems[0]); }
public void AssertCells() { // As a shortcut, you can iterate over all table cells through the ForEachCell method. Table.ForEachCell(cell => Assert.AreEqual("14px", cell.GetCssValue("font-size"))); // You can get a particular cell as BELLATRIX element mentioning the column header and row number. Table.GetCell("First Name", 1).ValidateInnerTextIs("Frank"); // You can get a particular cell as BELLATRIX element mentioning the row and column number. Table.GetCell(1, 2).ValidateInnerTextIs("Jason"); // You can get a particular cell by header expression and row number. Table.GetCell <User>(cell => cell.Email, 1).ValidateInnerTextIs("*****@*****.**"); // You can get particular cells by a selector. ElementsList <TableCell> cells = Table.GetCells(cell => cell.InnerText.ToLower().StartsWith('j')); Assert.AreEqual(4, cells.Count()); // As a shortcut, you can get the first cell matching a given condition through the GetFirstOrDefaultCell method. var matchingCell = Table.GetFirstOrDefaultCell(cell => cell.InnerText.ToLower().StartsWith('j')); matchingCell.ValidateInnerTextIs("John"); }