Automate testing tables

Selecting a row in a table

testRigor has a very powerful way of dealing with whatever looks like a table for a user.

You can refer to elements of the table by specifying row and column.
And to specify a row there is a powerful SQL-like language is available.
For example, you can say things like:

click "Delete" inside of table at row containing "my unique id" and column "Actions"

Here we didn’t specify the column where the “my unique id” should reside, but rather indicated that it could be in any column at that row.

You can also construct SQL-like expressions containing one or multiple columns with different validations. For example:

check that table with "Country" equal to "United States" and "City" equal to "Saint Petersburg" and "State" equal to "Florida" at column "Status" contains "Flourishing"

Here we used 3 different conditions to identify the row connected with the boolean operator AND. The following boolean operators are supported:

  • AND
  • OR
  • NOT
  • Brackets ()

and you can also use brackets. The condition calculation will follow the standard boolean logic. The condition above could also be expressed like so:

check that table with not("Country" not equal to "United States" or "City" not equal to "Saint Petersburg" or "State" not equal to "Florida") at column "Status" contains "Flourishing"

You can learn more about how boolean operators work here.

The exciting thing about testRigor is that these instructions would work regardless of how your table is rendered. It could be rendered as an HTML TABLE tag with TRs and TDs today and completely div-based tomorrow. It doesn’t matter, your code will continue to function anyway.

For an example, let’s consider the following table:

Actions
# Id Name Ship Status Actions
1 york1 Yorktown Enterprise Alright Arrive Cancel
2 spk2 Spock Enterprise Alright Listen to Ignore
3 nyo3 Nyota Enterprise Alright Open channel Promote
4 spk2 Spock Kelvin Alright Listen to Ignore
5 nyo3 Nyota Kelvin Alright Open channel Promote

In the example above, rows have no unique meaningful identifiers. We only have row numbers which might be generated automatically to show the index of a row. We can’t rely on them consistently because they will change the next time the page refreshes. How are we going to on a button with Spock and Kelvin? Here is how:

click on the first button in the context of table with "Name" equal to "Spock" and "Ship" equals to "Kelvin" at column "Actions"

Calculating aggregates

You can calculate and work with aggregate values on columns or specify a condition that would validate against all values in a column. Here are some examples:

Order of values

To check the order of the values contained in a row or column

check that table "actions" at column "Name" has values sorted in ascending order check that table "actions" at column "Name" has values sorted in descending order

Number of values (count)

To check the value count in a row or column

check that table "actions" at column "Name" the value count is greather than "3"
check that table "actions" at third column the value count is less than "20"
check that table "actions" at column "Name" the value count is equals to "5"
check that table "actions" at third column the value count is equals to stored value "expectedValueCount"

Sum of values

To check the sum of values in a row or column

check that table "actions" at column "#" the sum of values is greater than "10"
check that table "actions" at first column the sum of values is less than "50"
check that table "actions" at column "#" the sum of values is equals to "15"
check that table "actions" at first column the sum of values is less than stored value "expectedValueSummatory"

Average of values

To check the average of values in a row or column

check that table "actions" at column "#" the average of values is greater than "1"
check that table "actions" at first column the average of values is less than "6"
check that table "actions" at column "#" the average of values is equals to "3"
check that table "actions" at first column the average of values is equals to stored value "expectedValueAvg"