Skip to content

Instantly share code, notes, and snippets.

@RoyiNamir
Created November 13, 2018 13:53
Show Gist options
  • Save RoyiNamir/8ef0d85bf23eb9b61547d60446379785 to your computer and use it in GitHub Desktop.
Save RoyiNamir/8ef0d85bf23eb9b61547d60446379785 to your computer and use it in GitHub Desktop.
const getElementsAsync = (async (selector: string, section: ElementHandle | null, propertyName: string, page) =>
{
let cubes: ElementHandle[] = [];
if (section)
{
cubes = await section.$$(selector);
}
else
{
cubes = await page.$$(selector);
}
if (propertyName)
{
return await Promise.all(cubes.map(a=>getPropAsync(a,propertyName)));
}
else
{
return cubes;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment