Represents the table control (<table>). Default search finds the first occurring <table> element.

Inherited from Control.

Syntax

[ControlDefinition("table", IgnoreNameEndings = "Table")]
public class Table<THeader, TRow, TOwner> : Control<TOwner>
    where THeader : TableHeader<TOwner>
    where TRow : TableRow<TOwner>
    where TOwner : PageObject<TOwner>
public class Table<TRow, TOwner> : Table<TableHeader<TOwner>, TRow, TOwner>
    where TRow : TableRow<TOwner>
    where TOwner : PageObject<TOwner>
public class Table<TOwner> : Table<TableHeader<TOwner>, TableRow<TOwner>, TOwner>
    where TOwner : PageObject<TOwner>

Properties

public ControlList<THeader, TOwner>

Headers { get; }

Gets the headers list.

Table.Headers.Should.ContainHavingContent(TermMatch.Equals, "Name", "Amount");
public TableRowList<TRow, TOwner>

Rows { get; }

Gets the rows list.

Table.Rows.Should.HaveCount(2);
Table.Rows[0].Should.Exist();
Table.Rows[x => x.Content == "some content"].Click();

Example

<table id="products" class="table">
    <thead>
        <tr>
            <th>Name</th>
            <th>Amount</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Item 1</td>
            <td>5</td>
            <td><button>Delete</button></td>
        </tr>
        <tr>
            <td>Item 2</td>
            <td>10</td>
            <td><button>Delete</button></td>
        </tr>
    </tbody>
</table>
Name Amount Actions
Item 1 5
Item 2 10
using Atata;

namespace SampleApp.Tests
{
    using _ = SamplePage;

    public class SamplePage : Page<_>
    {
        [FindById]
        public Table<ProductTableRow, _> Products { get; private set; }

        public class ProductTableRow : TableRow<_>
        {
            public Text<_> Name { get; private set; }

            public Number<_> Amount { get; private set; }

            public Button<_> Delete { get; private set; }
        }
    }
}

Default search of the properties of type Content and inherited (e.g. Name and Amount) that are declared in the class inherited from TableRow is performed by the column header.

Go.To<SamplePage>().
    Products.Rows[x => x.Name == "Item 1"].Amount.Should.Equal(5).
    Products.Rows[x => x.Name == "Item 1"].Delete().
    Products.Rows[x => x.Name == "Item 1"].Should.Not.Exist();