Closed ljocampo closed 5 years ago
I'm also using styled-components (which do not have stable generated class names). My solution was to use babel-plugin-transform-react-qa-classes and use puppeteer-recorder's ability to specify a data attribute to track.
EDIT: I forgot that I had to fork that plugin.
@ljocampo this is normal expected behaviour from the (probably React) library you are using and has nothing to do with Puppeteer recorder. Best way to solve this is use @ephetic solution or add #ID tags to your elements.
Unfortunately the proposed solution is not viable for me since I do not have access to the source code of the site I'm puppeteering. Please consider having an option to use nth hierarchy.
@ljocampo puppeteer-recorder isn't actually generating these selectors itself, but instead uses @medv/finder, so it is where the change actually needs to be made. I would fork both of these repos and make the changes you need to your forks -- this would be the first step of creating a pull request to add this feature anyway and your team can install your fork as a dev Chrome extension.
@ljocampo @ephetic yes, in principle this would work. I just think I won't merge a forked repo that quickly. This stuff is hard for a good reason and would rather stick to a somewhat supported package.
@tnolet And you guys are working on a replacement for puppeteer-recorder, right? I have other customizations on my fork that suit my needs that I didn't bother opening PRs for. It's the way of open source.
@ephetic correct, everyone is totally free to do whatever they want on a fork.
Script records following selector:
Next time the page is reloaded for the same element selector has changed to: