Reputation: 312
I call this:
const wd = require('wd')
const driver = await wd.promiseChainRemote("http://localhost:4723/wd/hub")
elements = await driver.elementsByAccessibilityId("commonElementsId")
and I received a promise object. My question is, how do I get a single element to which I can apply text() method, so I get the text inside? I found a solution but it's for java. It looks like this:
elements.get(indexOfElement).getText()
This obviously doesn't work in javascript. Any ideas?
Upvotes: 0
Views: 1035
Reputation: 50809
You can't get the text of all the items in a list, you nned to loop over it
elements = await driver.elementsByAccessibilityId("commonElementsId")
for (i = 0; i < elements.length; i++) {
console.log(elements[i].text())
}
Upvotes: 1