playwright icon indicating copy to clipboard operation
playwright copied to clipboard

Support React forwards refs and memo

Open joaompneves opened this issue 2 years ago • 2 comments

This PR fixes the react selector behavior to support components that are wrapped by the memo or forwardRef React builtin functions.

Previously these components couldn't be selected. This PR fixes that behavior, enabling selecting those components.

Current behavior:

const Foo = memo(() => <div id="foo_component" />);
Foo.displayName = "Foo";
...
playwright.$("_react=Foo") -> undefined

Fixed behavior:

const Foo = memo(() => <div id="foo_component" />);
Foo.displayName = "Foo";
...
playwright.$("_react=Foo") -> <div id ="foo_component" />

joaompneves avatar May 24 '23 19:05 joaompneves

@microsoft-github-policy-service agree company="OutSystems"

joaompneves avatar May 25 '23 08:05 joaompneves

Hey @joaompneves, can you please add a test for this?

aslushnikov avatar May 25 '23 21:05 aslushnikov

Done. Seems that some tests are flacky

joaompneves avatar May 29 '23 10:05 joaompneves

Test Runner test results: https://mspwblobreport.z1.web.core.windows.net/run-5127460031-7e6e5f070630cd63c723b7390b329498abc2f9c9-test_test_runner/index.html

github-actions[bot] avatar May 31 '23 00:05 github-actions[bot]

Primary test results: https://mspwblobreport.z1.web.core.windows.net/run-5127460031-7e6e5f070630cd63c723b7390b329498abc2f9c9-test_linux/index.html

github-actions[bot] avatar May 31 '23 00:05 github-actions[bot]

Tracing test results: https://mspwblobreport.z1.web.core.windows.net/run-5127460034-7e6e5f070630cd63c723b7390b329498abc2f9c9-tracing_linux/index.html

github-actions[bot] avatar May 31 '23 00:05 github-actions[bot]