Giter VIP home page Giter VIP logo

Comments (8)

stevenmiller888 avatar stevenmiller888 commented on September 24, 2024

@kokujin Do you have a better idea for ensuring a unique path to the element? I'm sure there's a smarter way to do it, just haven't had time to think it over.

from daydream.

michalbe avatar michalbe commented on September 24, 2024

Maybe it would be smart to introduce a configuration where you can specify how the selectors will be calculated? With options like:

  • the dept of the selector - something like up to lvl 3 parents, etc.
  • list of classes to ignore
  • ignore parents at all if there is an id attr

from daydream.

kokujin avatar kokujin commented on September 24, 2024

I think that would open a can of worms @michalbe , It would be best it it would just automatically generate the shortest, most optimized selector.

Think about the scenario of allowing non technical users in a QA department.

from daydream.

kokujin avatar kokujin commented on September 24, 2024

Have you thought about using a third party lib to generate the electors @stevenmiller888 ? for example, https://www.npmjs.com/package/css-selector-generator, from the description:

it also generates shorter selectors and is faster and/or more robust than many other libraries - see this comparison and select the best alternative for your use case.

from daydream.

kokujin avatar kokujin commented on September 24, 2024

https://github.com/autarc/optimal-select is also an option to generate short selectors

from daydream.

michalbe avatar michalbe commented on September 24, 2024

Not sure if the first one is a good choice, apparently the lib has some infinite loops bugs inside.

There is a benchmark for this already: css-selector-generator-benchmark

from daydream.

justsml avatar justsml commented on September 24, 2024

RE @michalbe I'd love to also specify a black list of selectors.
A few "bad" selectors mess really mess my tests up.

from daydream.

roryrjb avatar roryrjb commented on September 24, 2024

@stevenmiller888 the pull request #32 has already solved this and I think this can be closed. In all my testing I haven't experienced any issues with long selectors.

from daydream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.