2

I need to extract the value from a particular table cell (e.g Row 3 + Column 5). below is the snippet from my current script which returns the value from the top row, but It can not go to a cell that is in the rows below the top row. The code was developed following the link

 it ('ESY_27 : Edit Button Click', function(){
    // get rows
    var rows = tableData_Dashboard.all(by.tagName("tr"));

    // get cell values
    var cells = rows.all(by.tagName("td"));


    var Student_ID = cells.get(0).getText().then(function(SID){
        console.log(SID);
    });
    var School_Name = cells.get(1).getText().then(function(SN){
        console.log(SN)
    });
    var StudentName = cells.get(2).getText().then(function(StN){

        console.log(StN);
    });
    var GradeLevel = cells.get(3).getText().then(function(GL){
        console.log(GL)
    });

    });

How can I access a particular table cell (like Row 3 & Column 4) and extract data from it using protractor?

nhrcpt
  • 862
  • 3
  • 21
  • 51

1 Answers1

2

Note: think about using async / await since it will help when the control flow is deprecated (in the next version of Protractor). The following snippet uses async / await and only gets the text from row 3 and column 4.

it ('Get row 3, get col 4', async () => {
  // get row 3
  const row = tableData_Dashboard.all(by.tagName("tr")).get(2);


  // get cell 4 (grade level)
  const cell = row.all(by.tagName("td")).get(3);
  console.log(await cell.getText());
});
cnishina
  • 5,016
  • 1
  • 23
  • 40