JavaScript object that creates a unique CSS selector for a given DOM element. It has no external dependencies.
Help support the project:
var generator = new SelectorGenerator();
var element = document.querySelector("input"); // <input type="text" id="login" />
var selector = generator.getSelector(element); //=> #login
var path = generator.getPath(element); //=> body > div > input
To install SelectorGenerator module for Node.js, this command should be used:
npm install selector-generator
Or yarn:
yarn add selector-generator
You can view the results of the SelectorGenerator test suite in your browser!
This software is distributed under the terms of the MIT License (MIT).
Alexander Chermyanin / LinkedIn
Contributions and bugs reports are welcome.