Chrome DevTools DOMPath implementation
npm install chrome-dompathThis package is a little piece of Google's Chromium DevTools project which modified to make it work on JSDOM.
The DOMPath is responsible for generating a selector given an element in a particular DOM hierarchy.
Its methods can be accessed via the following menu:
``Open DevTools -> Navigate to Elements tab -> Right click on selected Element -> Copy`
!DOMPath-use
npm i -S chrome-dompath
`DOMPath
Get selector, JS Path and XPath of a DOM element.
`js
const DOMPath = require('chrome-dompath');// Node
const dom = new JSDOM('T1T2 ').window.document;
const element = dom.querySelector('b');
// Browser
const element = window.document.querySelector('b');
DOMPath.fullQualifiedSelector(element, true);
DOMPath.jsPath(element, true);
DOMPath.xPath(element, true);
`API
$3
Returns the full qualified selector (string) for the node supplied.
`js
DOMPath.fullQualifiedSelector(element);
DOMPath.fullQualifiedSelector(element, true);
`$3
Returns the JS path (string) for the node supplied.
`js
DOMPath.jsPath(element);
DOMPath.jsPath(element, true);
`$3
Returns the xpath (string) for the node supplied.
`js
DOMPath.xpath(element);
DOMPath.xpath(element, true);
``