'ReactSelector can not access all components
i am new to React and Testcafe and have to write some end-to-end tests. I thougt, it was a good idea to mainly use the ReactSelector from 'testcafe-react-selectors', but i can not access all components although they are accessible via the 'React Developer Tools' Components view in the DevTools of the browser (edge).
Can anyone give me a hint as to why this is the case?
best regards sebastian
Solution 1:[1]
I now found the issue: the elements, that i can't select, are forwardrefs. It is an already known bug in testcafe-react-selectors
It seems that there is a workaround in using ReactSelector('WithStyles(ForwardRef(TextField))')
instead of ReactSelector('TextField')
.
I'm not sure, if this is really a good way to do this, so i ditched the react-selectors and now use only data-testids
.
Solution 2:[2]
I need to reproduce the problem locally to be able to assist you. If you manage to create a sample project, please create an issue in the TestCafe GitHub repository and add it there together with the information required to reproduce the incorrect behavior.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Alexey Filin |