I can't seem to find the correct syntax for iterating through the innerHTML of a nodelist in Nightwatch. I'm trying to return the urls of every 'a' tag contained within the body content of a page, but I can't find a way to access the results of my querySelectorAll command in Nightwatch.
browser.execute(function() {
return document.querySelectorAll("div.field-item.even a");
},
function(tags){
console.log(tags.value);
console.log(tags.value[9]);
})
There are 10 links on the page I am testing. The query selector seems to be retrieving them all, since console.log(tags.value) prints the following:
[ { ELEMENT: '1' },
{ ELEMENT: '2' },
{ ELEMENT: '3' },
{ ELEMENT: '4' },
{ ELEMENT: '5' },
{ ELEMENT: '6' },
{ ELEMENT: '7' },
{ ELEMENT: '8' },
{ ELEMENT: '9' },
{ ELEMENT: '10' } ]
and console.log(tags.value[9]) prints:
{ ELEMENT: '10' }
I cannot find a way to retrieve the link from these results, however. Appending .innerHTML to any of these variables returns 'undefined'. Is there any way for me to iterate through the querySelectorAll results and retrieve the urls inside of it?
EDIT: It seems like I can get the same result if I use the following code:
browser.elements("css selector", "div.field-item.even a", function(tags) {
console.log(tags.value);
console.log(tags.value[9]);
})
I originally thought that I was working with a nodelist, but I think I'm actually being returned a WebElement JSON object as per the documentation for the .elements command.
I'm still unable to access the inner text, however. Any ideas?