Reputation: 49
I'm trying to loop over some table and get the innerHTML() but when I try to do it I get innerHTML is not a function. I've looked over the documentation and findElements should return an array but if I check the type of item is an object
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('https://stackoverflow.com/');
driver.findElements(By.xpath('//*[@id="question-mini-list"]/div'))
.then(function(item) {
console.log( item );
});
Upvotes: 0
Views: 1730
Reputation: 2109
From their GitHub, findElements
returns an Array
, which contains Elements
(objects!).
findElements: function(scope) {
var element;
if (element = $(this.params.id))
if (this.match(element))
if (!scope || Element.childOf(element, scope))
return [element];
scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
var results = [];
for (var i = 0; i < scope.length; i++)
if (this.match(element = scope[i]))
results.push(Element.extend(element));
return results;
}
To get the innerHTML, you can use the getAttribute
function on the element:
item[0].getAttribute('innerHTML');
Upvotes: 2