5

How can I write a Cucumber step that has two DataTables?

How it should be written in the feature file?

For example , a step to drag a row from one table to second table:

When I drag a row from  
   | column_table1 |   
   | object1       |  
to   
   | column_table2 |   
   | object2       | 
Dan Getz
  • 8,774
  • 6
  • 30
  • 64
Avi Rosenfeld
  • 305
  • 3
  • 7
  • 19

1 Answers1

8

There is no special syntax to add a second table. Just add it.

When I drag a row from:
| column_table1 |   
| object1       |  
And I drop it at:
| column_table2 |   
| object2       |  

AFAIK, you can only have one table per step, but you can have as many steps with tables as you want. One way I approach the problem is storing the tables in a variable to often reference in a third step:

Given I have a source row from:
<table>
And I have a destination row at:
<table>
When I drag from the source row and drop at the destimation row
Then .....
Jeff Price
  • 3,229
  • 22
  • 24
  • Thanks Jeff, this is nice workaround. Still it was nice if there was a way to rinclude two DataTables in a step with a separator between them. – Avi Rosenfeld May 12 '16 at 17:12
  • You could "fake" it by adding another column to hold the "table" name. But I really think that would be more effort than it's worth as you'd have to deconstruct the one table into the mutliple tables you desired. – Jeff Price May 12 '16 at 18:14