Tables
DrevOps\BehatSteps\Steps\Web\TableTrait - Source, Example, Helpers
Interact with HTML table elements and assert their content.
- Assert table row and column counts.
- Assert table column headers.
- Assert table empty and non-empty states.
- Assert table sort order by column.
- Assert text values present in a specific table row.
- Assert bulk row content against expected values.
- Click links and press buttons within a row identified by part of its text.
Options
| Option | Type | Default | Tag | Description |
|---|---|---|---|---|
table.header_selector | string | 'thead tr th' | - | CSS selector of a table header cell, relative to the table. |
table.body_row_selector | string | 'tbody tr' | - | CSS selector of a table body row, relative to the table. |
Steps
@When I follow the link :link in the row containing :partial_text
Click a link within a row
When I follow the link "Edit" in the row containing "Article title"
@When I press the button :button in the row containing :partial_text
Press a button within a row
When I press the button "Remove" in the row containing "Article title"
@Then the table :selector should have :count row(s)
Assert that a table has the expected number of body rows
Then the table ".mytable" should have 5 rows
@Then the table :selector should have :count column(s)
Assert that a table has the expected number of columns
Then the table ".mytable" should have 5 columns
@Then the table :selector should contain the following columns:
Assert that a table contains the expected column headers
Then the table ".mytable" should contain the following columns:
| Title |
| Author |
| Status |
@Then the table :selector should be empty
Assert that a table is empty (has no body rows)
Then the table ".mytable" should be empty
@Then the table :selector should not be empty
Assert that a table is not empty (has body rows)
Then the table ".mytable" should not be empty
@Then the table :selector should be sorted by :column in :direction order
Assert that a table is sorted by a column in a specific direction
Then the table ".mytable" should be sorted by "Title" in "ascending" order
Then the table ".mytable" should be sorted by "Date" in "descending" order
@Then the table :selector should contain the following rows:
Assert that a table contains the expected rows
Then the table ".mytable" should contain the following rows:
| Title | Status |
| Article 1 | Published |
| Article 2 | Draft |
@Then I should see the following text in the row containing :partial_text:
Assert that a table row containing a text has the expected values
Then I should see the following text in the row containing "Article title":
| Published |
| admin |
@Then I should see the text :text in the row containing :partial_text
Assert that a row contains a string
Then I should see the text "Published" in the row containing "Article title"
@Then I should not see the text :text in the row containing :partial_text
Assert that a row does not contain a string
Then I should not see the text "Unpublished" in the row containing "Article title"
@Then I should see the link :link in the row containing :partial_text
Assert that a row contains the link
Then I should see the link "Edit" in the row containing "Article title"
@Then I should not see the link :link in the row containing :partial_text
Assert that a row does not contain the link
Then I should not see the link "Delete" in the row containing "Article title"