Reputation: 81
The element.all() returns an array of webelements. I'd like to be able to further process these elements. Example would be element.all(by.something()).each(function(row) { var button = row.element(by.buttonWithText("cancel")).then(....
But of course, I can't use row.element because row is a webelement, not an elementFinder.
Is there an easy way of converting a webElement to a elementFinder?
I was thinking of getting the xpath to the webElement then using by.xpath() but that seems like overkill.
Upvotes: 3
Views: 2019
Reputation: 139
element.all()
Should return an ElementArrayFinder that you can treat as an Array of ElementFinders, so you should not need to convert it. You have further information in the linke below:
ElementArrayFinder Documentation
Upvotes: 0
Reputation: 1607
I'm pretty sure that's ok or you could try something like this
ptor.findElements(protractor.By.tag('tr')).then(function(rows){
rows[0].findElement(protractor.By.linkText('something')).click();
});
that should work as you want it to i use this structure in a few places. If you were to use findElement this would work in the same way only it wouldn't be an array so it would be ..rows.findElement..etc
Upvotes: 1