-
Notifications
You must be signed in to change notification settings - Fork 36
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
React selectors #28
Comments
Hi @pdufour! Sorry I totally missed this issue in my GH notifications. Absolutely would love contributions. Here's two approaches I can think of (one being the pragmatic one, the other being quite ambitious). Hacky SolutionThe hackiest and likely easiest way is to create a new Next you'll need to actually generate the selector that can be used, I'm not sure if this is easy to do so as you'll need to convert HTMLElement -> component name (perhaps there is a React API to do so?). Though if you can do that, you'll just need to add a new property returned from Once a new script type is defined and the selector is returned from Once this is done, you'll want to update the script generator logic to actually output code for your new At this point, you'll only need to update the UI to actually show the option to the user, which should only involve adding a new option to this component, but I'd double check when manually testing just in case we haven't migrated any selectors over to this centralized selector component. Nicer solution?A nicer solution is likely allowing the user to choose (at action-time or post code-gen) what kind of selector they'd like to use for a given action. This would likely require a pretty big change to the If you want to take on a nicer solution, the above functions are a good starting point to look at (I'd imagine it's either modifying Sorry I know the above is probably a mouthful, but hopefully can serve as some insight into the inner mechanisms of the extension :) |
I've noticed if you are using React things are typically a lot easier to select using the new(ish) React selectors playwright supports. https://playwright.dev/docs/selectors#react-selectors. This is because a lot of times you would not have assigned unique classes / ids to your dom elements unless you set up your app with this concept from the start.
Would you accept a PR to add support for using React selectors instead of classes etc? Maybe have an option in the UI to toggle between the two? And any idea how I could get started with those changes?
Thanks.
The text was updated successfully, but these errors were encountered: