0

I have a table that and I would like to validate the data shown on the table using a cucumber Scenario Outline. I know you can use one to repeat a similar series of steps, but is it possible to use the data table to validate what is on say a 4x4 table? so if my example looked like ..

Examples:
| name | age | disabled | insured |
| Tim  | 56  |        N |       N |
| Bob  | 72  |        Y |       N |
| Lee  | 52  |        Y |       Y |
| Mat  | 34  |        N |       N |

And this was an exact copy of what is on the UI, I want this to go row by row and validate what is on the screen.

Tree55Topz
  • 1,102
  • 4
  • 20
  • 51

2 Answers2

0

There are two ways to do.

  1. Go through each datatable row and compare it with actual row cell by cell.

  2. Transform actual table on web page using WebDriver into List>. Then it is possible to compare tables by tableFromGherkinStep.diff(actualTableFromPage).

  • I have seen this solution for java, but this in cucumberjs. The implementation of the page objects and the step definitions is far different. – Tree55Topz Nov 22 '16 at 17:40
0

I'd push this validation down into the step definitions by giving that table a name say 'sample_users' and then writing a step

Then 'I should see the sample users'

and implementing that with

Then 'I should see the sample users' do
  check_sample_users
end

and now you are out of cukes and into your native language and you can easily compare two tables. You can also choose a better location for the canonical definition of what the table should look like. Using a scenario for this is not a good idea.

diabolist
  • 3,990
  • 1
  • 11
  • 15