Puppeteer: Support for Ember Dynamic Selectors

Created on 4 Dec 2017  ·  3Comments  ·  Source: puppeteer/puppeteer

Does Puppeteer have support for Ember dynamic selectors?

The Ember framework provides each element with a unique id in the format ember2599.
Is there a way to select the nth ember* element? or some other method?

Any code example is appreciated.

Thanks!

Most helpful comment

Untested code ahead!

function nthEmberElement(n) {
    return page.evaluateHandle(n => Array.from(document.querySelectorAll('*')).filter(element => element.id.startsWith('ember'))[n], n);
}

await (await nthEmberElement(5)).click();

All 3 comments

Would also like to know this :) It was mentioned that #382 would fix this, but I'm still not sure how 🤔

Untested code ahead!

function nthEmberElement(n) {
    return page.evaluateHandle(n => Array.from(document.querySelectorAll('*')).filter(element => element.id.startsWith('ember'))[n], n);
}

await (await nthEmberElement(5)).click();

Super helpful @JoelEinbinder! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

namma-geniee picture namma-geniee  ·  3Comments

sradu picture sradu  ·  3Comments

kesava picture kesava  ·  3Comments

ryanvincent29 picture ryanvincent29  ·  3Comments

barnash picture barnash  ·  3Comments