dom-to-selector
Generates unique selector for DOM Node.
Installation
npm install --save dom-to-selector
Usage
const dom = require('dom-to-selector');
const node = document.getElementsByClassName('foo')[0];
const selector = dom.stringify(node);
console.log(node === dom.parse(selector)); //true
Tests
npm test