Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Ember Dynamic Selectors #1536

Closed
denniscieri opened this issue Dec 4, 2017 · 3 comments
Closed

Support for Ember Dynamic Selectors #1536

denniscieri opened this issue Dec 4, 2017 · 3 comments

Comments

@denniscieri
Copy link

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!

@tomredman
Copy link

tomredman commented Dec 4, 2017

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

@JoelEinbinder
Copy link
Collaborator

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();

@tomredman
Copy link

Super helpful @JoelEinbinder! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants