I am attempting to confirm the number of rows and columns in a table by using Protractor/Js.
After testing four different functions, I have received inaccurate results. My suspicion is that my locator, which is '.tsc_table_s13', may be incorrect.
For Rows:
$(locator).all(by.xpath('.//tbody/tr')).count().then(function (data) {
expect(data).to.equal(parseInt(myCount));
});
Alternatively...
var table = element.all(by.css(locator));
table.all(by.tagName("tr")).count().then(function (data) {
expect(data).to.equal(parseInt(mycount));
});
For Columns:
$(locator).all(by.xpath('.//tbody/tr/td')).count().then(function (data) {
expect(data).to.equal(parseInt(myCount));
});
Alternatively...
var table = element.all(by.css(locator));
table.all(by.tagName("td")).count().then(function (data) {
expect(data).to.equal(parseInt(myCount));
});
When checking the column count, I receive 25 (or 26) when I should only have 6. The row count shows 0 instead of the expected 4. You can view the table here -