Here is exactly what I\'m trying to do
I open a page with a table that contains information about users
I getText() of element that indicates a number of use
To be honest I didn't what are you checking.
First of all you should consider using
element.all(by.xpath("(//td[@data-field='username'])"))
instead of
element(by.xpath("(//td[@data-field='username'])["+j+"]"))
It returns elementArrayFinder.
Assign it to a variable (eg. tableRows
) and then you can handle with those data.
If you are trying to check whether the number in a string "11 Users in list" is correct, yuu can use tableRows.count()
You can also filter
elements:
http://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.filter
use map
:
http://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.map
Drop me a line what exactly test should do.
Edit:
Ok. Here you have code sample.
It clicks EDIT
link of defined user (TESTUSER26 in this case):
The only change you have to make is change defineSelectorForUsernameCell
into real value.
var tableRows = element.all(by.css('td'));
var searchedUsername = 'TESTUSER26';
return tableRows.filter((eachRow) => {
return eachRow.element(by.css('defineSelectorForUsernameCell')).getText((usernameCellText) => {
if (usernameCellText === searchedUsername) {
return eachRow.element(by.linkText('EDIT')).click();
}
});
});