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

Setting dataAttribute does not work for clicks on nested elements #1

Open
scharf opened this issue Jun 13, 2019 · 4 comments
Open

Setting dataAttribute does not work for clicks on nested elements #1

scharf opened this issue Jun 13, 2019 · 4 comments

Comments

@scharf
Copy link

scharf commented Jun 13, 2019

I have a case where I have a structure like this (I have set the dataAttribute to data-testid in the settings):

<li data-testid='some-id'>
   <a href="...">a label</a>
</li>

The reason, I cannot set the data-testid on the a is, because I use a UI library and that only allows me to set data attributes on the outer element and not on the inner element.

If I click on the <a>..</a>, I would expect, that the selector is [data-testid=some-id] > a but it does not recognize the dataAttribute in the parent of the clicked item.

I think it is probably a problem with @medv/finder. It seems finder does not support to look for data- attributes.

What you could do: walk up the tree (to some level) and until you find a dataAttribute and then use this as root for @medv/finder. And merge the two selectors.

If you want, I can provide some help for doing this, but it should be relatively straight forward....

@oscartavarez
Copy link
Owner

oscartavarez commented Jun 14, 2019 via email

@jpike88
Copy link

jpike88 commented Jun 17, 2019

@oscartavarez this is a great library, I think you'll get strong attention from the Cypress team if this does a good job. good luck

@fmoliveira
Copy link

fmoliveira commented Sep 21, 2019

@oscartavarez I've had the same issue in a project that uses react-intl for i18n, which adds children span tags to every processed string. When recording, the innermost span tags are clicked most of the times, so, no data attributes are recorded in most attempts.

I've fiddled a little bit with the code and came up with a solution that my team have been using for a few weeks with no problems, but I'm not sure if that's the best solution.

I've opened a PR at #4 to discuss about my solution.

@wolfi3b
Copy link

wolfi3b commented Dec 3, 2019

Hi guys..absolutely cool extension! Thank you a lot making it!

Just wanted to ask as this nested selection when clicking is kinda problem. Any progress there?

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

5 participants