示例#1
0
        public void AssertMiscData()
        {
            // You can get all rows as instances of a specific class through the GetItems method.
            Assert.AreEqual(_expectedUsers[0].Email, Table.GetItems <User>()[0].Email);

            // Compares all table rows to the expected entities. Each row is internally converted to the type of the expected entities.
            Table.AssertTable(_expectedUsers);

            // You can get all header names. Doubled headers are returned as one entry and separated by space.
            Assert.AreEqual("Action", Table.GetHeaderNames().Last());
        }
示例#2
0
        public void AssertColumns()
        {
            // You can get the cells of a particular column mentioning the column number.
            var secondColumn = Table.GetColumn(1);

            Assert.AreEqual("John", secondColumn[0].InnerText);

            // You can use built-in BELLATRIX Validate methods to assert the cell attributes.
            secondColumn[0].ValidateInnerTextIs("John");

            // You can get the cells of a particular column mentioning the column name.
            secondColumn = Table.GetColumn("First Name");
            Assert.AreEqual("John", secondColumn[0].InnerText);

            secondColumn[0].ValidateInnerTextIs("John");
        }
示例#3
0
        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.
            List <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]);
        }
示例#4
0
        public void AssertSpecificCell()
        {
            var firstCell = Table.GetCell(0, 0);

            // You can get the cell row and column.
            Assert.AreEqual(0, firstCell.Row);
            Assert.AreEqual(0, firstCell.Column);

            // You can get the cell innerText.
            Assert.AreEqual("Smith", firstCell.InnerText);

            // You can use built-in BELLATRIX Validate methods to assert the cell attributes.
            firstCell.ValidateInnerTextIs("Smith");

            // You can get the cell innerHtml.
            var thirdCell = Table.GetCell(0, 2);

            Assert.AreEqual("Doe", thirdCell.InnerHtml);
        }
示例#5
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.
            List <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");
        }