1

I was wonder if someone found an easy way to verify a selector work properly with the TestCafe syntax without running the entire test over and over?

E.g: I want to verify that the last table column cells has all the values in a array I provide:

in order to do I try to detect the last column but for validation, I have to execute the entire testcafe test from start. How do you recommend approaching this scenario? The following snippet I wrote to verify I catch all the right column cells, but it took me a while because each time I had to run the test again.

console.log(`total rows: ${await (Selector('tbody > tr').find('td:nth-of-type(3)')).count}`);

Another thing, how I save to array the most right column cells?

Source: Table for example

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
teslaTanch
  • 93
  • 9

1 Answers1

3

Stay tuned to Selector Debug Panel feature.

As for your 'save to array the most right column cells' question, selector provides methods and properties to select elements on the page and get their state, but has no 'rows' and 'columns' properties. So, you can use the following approach to iterate over your table cells:

const table       = Selector('#table');
const rowCount    = await table.find('tr').count;
const columnCount = await table.find('tr').nth(0).find('td').count;

for(let i = 0; i < rowCount; i++) {
    for(let j = 0; j < columnCount; j++) {  
        let tdText = await table.find('tr').nth(i).find('td').nth(j).textContent;
    }
}

and add required cells to an array inside the loop