How to get table column values as Array using jquery in Protractor

I am working on a project, there is a table which gets created dynamically. i want get the column values from table as Array using jquery.

this is what i have done so far, but i am getting this error.

Failed: unknown error: arguments[0].push is not a function

code :

    var myArray = [];
    browser.executeScript("$(document).ready(function() { $('.table tbody tr td:nth-child(5)').each(function(i){ arguments[0].push($(this).text());});});",myArray);
    console.log(myArray);

please help me. Thank u

Answers 1

  • You can simply use protractor's getText() method on ElementArrayFinder to get the value as an array. Try the below code.

    element.all('.table tbody tr td:nth-child(5)').getText().then(function(textArray){
       console.log(textArray);
    })
    

Related Articles