javascript map async await

Developer from somewhere

Problem: want to obtain the text from an array of elements

Solution:

  • Promise.all and async await map:
const childrenTable = await driver.findElement(By.css('table'))
const childrenEntries = await childrenTable.findElements(By.css('tr'))
const childrenText = await Promise.all(childrenEntries.map(async (cd) => cd.getText()))