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

selfrefactor picture selfrefactor  路  3Comments

aslushnikov picture aslushnikov  路  3Comments

sradu picture sradu  路  3Comments

td0m picture td0m  路  3Comments

pyper picture pyper  路  3Comments