Accessibility First DevRel. I focus on ensuring content created, events held and company assets are as accessible as possible, for as many people as possible.
I'm Disgusting Dev - interested in CaaS (Codebase as a Service) solution and willing to increase knowledge of Dev Community about different problems and their solutions
Fella, if you are about to create xPath generator, I suggest you to create browser extension for this - I believe there will be a lot of those QA guys who need as fast as possible to get in clipboard such an xpath for e2e testing (yes, I'm talking about those who don't use test ids) - and much better if it defines id or data-id etc. of element and minimize your path just to it
Accessibility First DevRel. I focus on ensuring content created, events held and company assets are as accessible as possible, for as many people as possible.
It already uses the id if you look at the code, first thing it checks for and returns early if found.
Plus this is used as part of an analytics package to track clicks, the being able to click on things is just to demonstrate.
If you wanted you could easily turn it into a bookmarklet and have the ID copied to the clipboard, no need to build a browser extension for something so simple, especially when you can get the Xpath with developer tools really easily.
Had to bookmark this as it could be a great base for a library I work on and I like your implementation.
Here is my implementation, but it generates the the
Xpath
to the item instead of a unique selector.One thing you should steal is the returning early if the item has an ID (as obviously the ID should be unique) just to save on selector complexity.
Fella, if you are about to create xPath generator, I suggest you to create browser extension for this - I believe there will be a lot of those QA guys who need as fast as possible to get in clipboard such an xpath for e2e testing (yes, I'm talking about those who don't use test ids) - and much better if it defines id or data-id etc. of element and minimize your path just to it
It already uses the id if you look at the code, first thing it checks for and returns early if found.
Plus this is used as part of an analytics package to track clicks, the being able to click on things is just to demonstrate.
If you wanted you could easily turn it into a bookmarklet and have the ID copied to the clipboard, no need to build a browser extension for something so simple, especially when you can get the Xpath with developer tools really easily.
Thanks :)
Here is some reference: stackoverflow, sitepoint.
I will try it.