Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

IDEA does not allow me to use table.raw();

I am new in cucumber so while I was learning/practising I tried to get the data from a DataTable by the following code

public void iEnterTheFollowingForLogin(DataTable table) {

    List<List<String>> data = table.raw();

    System.out.println("The value is : "+ data.get(1).get(0).toString());

    System.out.println("The value is : "+ data.get(1).get(1).toString());

}

I realized that IDEA type the raw method in red so I think maybe it is obsolete and now I should use a newer one.

1 Answer

0 votes
by (62.9k points)

Rather than accessing the raw table you can address individual cells directly using cell(row, column) or use cells() to get a list of lists.

import io.cucumber.datatable.DataTable; 

import java.util.List; class Scratch {

 public static void main(String[] args) {

 DataTable data = //...create data table here 

System.out.println("The value is : " + data.cell(1, 0)); 

System.out.println("The value is : " + data.cell(1, 1)); 

List<List<String>> cells = data.cells(); 

System.out.println("The value is : " + cells.get(1).get(0)); System.out.println("The value is : " + cells.get(1).get(1));

 } 

}

Browse Categories

...