Search code examples
reactjstestingautomated-testse2e-testingtestcafe

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

  • 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.