Search code examples
javascriptdalekjs

get the amount of rows in a table


I want to get the amount of rows in a table on my page. I am trying to do this using .execute(function(){}) but how is it possible to get a variable out of the execute function and use it there. this isn't the counter yet, buy i can't even get a variable to work. i tried something like this:

.execute(function(){
    global.amountOfRows = 5;
})

.assert.numberOfElements('#content-list > tbody > tr', global.amountOfRows)

i tried the same using var amountOfRows = 5;

Any ideas?


Solution

  • Using jquery to return the number of row in your table body

    $('#your_table_id tbody').find('tr').length;
    http://api.jquery.com/length/ 
    

    I tried this but it didnt work out as planned.