How to control table data
The title is a little complex but corresponds to a case that is often encountered in automated software tests:
You want to control the values of a cell that is located on the same line as another cell that you know.
For example, in the table above, we want to control that Chromium is well availiable on Android, ie that there is Yes in the Android column of the Chromium line.
Agilitest allows you to do it simply by a text aggregation trick: if you select the corresponding TR line of the Chromium table, you will be able to retrieve a TEXT attribute which is a concatenation of all the values of the cells of the line.
The text value of the TR line containing Chromium is as follows:
Chromium Yes Yes Yes Yes Yes No No
The value you want to control is the 5th Yes.
To retrieve the line that matches Chromium without assuming any of the following values, your locator will look like this:
(?i) indicates that the control must be case insensitive
\s corresponds to a space
(.*) corresponds to any type of text, by inserting with \s, it corresponds to text before a space, the "greedy" behavior of regular expressions will then try to match as many characters as possible.
Then we will create a variable that will retrieve the specific value in the Android column.
We use the following regular expression:
The corresponding group is the 6th
It is then enough to make a control of value:
We can add several comments to this trick:
First, you have to master the data of your tests, so it can be dangerous to use this technique when you don't know where is the Chromium line in the table. You can end up with a slightly lax test that does not really know where the data is.
So adapt this technique on a case-by-case basis, for example if your test data is not yet fixed and you do not want to modify your test too often.
It is also possible to use it if you do Data Driven Testing, the controls set up will adapt to the data you have defined in a CSV file. In this case precautions should be taken: for example "Internet Explorer" contains a space that will be used by the regular expression and shift all the data you will want to control.
To finish with this example, you can use a "Check Values" action to control the entire Chromium line at once. You control all of a sudden but you will not know in case of failure what value was not in conformity.