testcafe-react-selectors
testcafe-react-selectors copied to clipboard
Can't find desendant components of the same type
I have two instances of a component one of which is desendant of another (with a div wrapper between them). ReactSelector('Foo').count
returns 1.
Yep, this does not work... I have component named Id and structure like:
<div>
<Id name="one">
<div>
<Id name="two">
foo
</Id>
</div>
</Id>
</div>
I can try then:
const one = await ReactSelector('Id').withProps({
name: 'one'
});
const two = await one.findReact('Id').withProps({
name: 'two'
});
await t.expect(one.count).ok('One was found');
await t.expect(two.count).ok('Two was found'); // <-- This fails as two.count = 0
Hi @leomelin, Yes, the current implementation doesn't allow to use such selectors. I'm going to investigate and try to figure out a fix soon.
No idea how this issue still exists when such functionality is so common. For something like
Row
Container
Container key='1'
Container key='2'
Container
...
Container
...
How am I supposed to be able to select the containers with keys so that I can verify the key values are correct?
I'm able to select the first container fine with section = ReactSelector('Row Container').nth(0);
but then selecting the two containers inside that is seemingly impossible.
-
section.findReact('Container');
does not work, it only returns the original container itself -
section.findReact('Container Container').nth(x);
also does not work
What's even stranger is that at seemingly random times, section.findReact('Container Container').nth(x);
does actually work, but not in any reproducible way.
The hack that I'm currently using is section.find('.container').nth(0).findReact('Container').getReact(({ key }) => key))
Hi @joywave,
Thank you for your feedback and for the workaround. Once we get any results, we will post them here. You are also welcome to submit your PR.
This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.
We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.
Hello I encountered the same error. When searching for nested items with the same name. The reactive selector can only select the parent. For example
<ComponentA key="componentAParent">
<ComponentA key="componentAChild" />
<ComponentB key="componentBChild" />
</ComponentA>
Example 2:
<ComponentA key="componentAParent">
<SomeComponent>
<ComponentA key="componentAChild" />
<ComponentB key="componentBChild" />
<SomeComponent>
</ComponentA>
ReactSelector("ComponentA").withKey("componentAParent") - can find parent but ReactSelector("ComponentA").withKey("componentAChild") - can't find the nested element
Could you please help us with this issue?
Hi @ilya2010ujl,
I see that the problem is still actual. I'll reopen the issue.
This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.
We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.