I'm trying to locate an element using protractor but I can't find it. To debug, I'd like to look at the element I did find and see which one it is. I have some code like this:
myElement.all(by.cssContainingText('.name', 'value')).then(function (elems) {
console.log(elems.length); <--- this line logs "2"
console.log(elems[1]); <--- this line logs "{ ptor_: ...."
elems[1].getInnerHtml().then(function(html){
console.log(html); <--- never gets here
}); });
How can I see what elements the all() method found?
Not sure if it's the best/most concise way, but you should be able to use map to loop over the elements, and use getOuterHtml() on each to access the HTML
myElement.all(by.cssContainingText('.name', 'value')).map(function(el) {
return el.getOuterHtml();
}).then(function(html) {
console.log(html);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With