Comments (5)
Plus 1 for this feature.
this would give the users the possibility to prioritize criteria.
maybe not just prioritizing certain attributes over other attributes, but maybe also lower the priority of class or tag-name over attributes in general or certain attributes like the mentioned data-testid
.
Ps: we are using your library in Robot Framework Browser, which is a Playwright based library for Robot Framework. We added your lib in June 2021 and we are super happy about your contribution!
https://robotframework-browser.org/ š
from finder.
Iām thinking about the good API design for such feature.
@antonmedv how about a new option called as penalties
with the type
type penalties = {
idName?: (name: string) => number;
attr?: (name: string, value: string) => number;
className?: (name: string) => number;
tagName?: (name: string) => number;
};
Or can change the type of the existing idName
, className
, tagName
, attr
properties to support a number
output that can be the penalty value in addition to the existing boolean
export type Options = {
idName: (name: string) => boolean | number
className: (name: string) => boolean | number
tagName: (name: string) => boolean | number
attr: (name: string, value: string) => boolean | number
...
}
from finder.
Well, I guess something like a config for custom penalties can be added.
Currently, now all attr gets a penalty: 0.5
.
from finder.
Well, I guess something like a config for custom penalties can be added.
Currently, now all attr gets a
penalty: 0.5
.
@antonmedv That would be a good idea. With that one can choose to give a negative penalty for any attribute that needs to be prioritised to generate more reliable selectors. For example, data-testid
attributes.
from finder.
Iām thinking about the good API design for such feature.
from finder.
Related Issues (20)
- The execution speed is relatively slow HOT 4
- Consider caching/memoizing "unique" function HOT 2
- Selector not found HOT 1
- CDN Stopped working HOT 3
- Selector was not found for all the elements on page
- Selector not found HOT 6
- Argument of type 'Node' is not assignable to parameter of type 'Element'. HOT 1
- [feature request] - generation of 'alternate' selector HOT 3
- [feature request] Add config option to include structural/semantic elements HOT 7
- Prefer `[id="123"]` vs. `#\31 23` HOT 1
- cssesc vs CSS.escape HOT 3
- Support multiple elements HOT 4
- root config doesn't allow Document HOT 1
- Uncompiled `finder.ts` file is a target of compilation by typescript HOT 1
- Finder Timeout HOT 2
- Support for XML namespace prefixes in DOM Element names / tagnames (XHTML, SVG, MathML), with proposed fix HOT 1
- Thought out loud - Chrome Extension
- [Feature Request] find path for multiple elements and find closest common parent HOT 2
- [Bug] Potential memory exhaustion when a high number of classes exist at multiple levels in the DOM HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from finder.