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

[Enhancement] Target specific element in selector results that match more than one #1115

Closed
senocular opened this issue Aug 2, 2016 · 0 comments

Comments

@senocular
Copy link
Contributor

senocular commented Aug 2, 2016

Sometimes you have a selector which results in multiple element matches but only want one of those elements - not the first which, by default, is the one always used. CSS does have nth pseudo-classes, but they're limited in what they can do. Xpath is better, supporting array access syntax (//<path>[0]) for targeting elements like this, but sometimes it doesn't always cut it, such as when using page objects with @-element references. In that case, the index would be fixed in the element definition when maybe you want to reuse that same reference to target multiple elements in that query ([0], [1], etc.).

browser.setValue('input', 'username'); // how to target 2nd input element?
page.click('@button'); // or the 3rd button?

Being able to specifically target an element by an index within a resulting elements query would be nice.

senocular added a commit to senocular/nightwatch that referenced this issue Aug 2, 2016
senocular added a commit to senocular/nightwatch that referenced this issue Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants