Converts CSS3 selectors to their XPath equivalents.
var cssToXPath = require('css-to-xpath');
cssToXPath('p:not(:has(a.x))');
...returns the string:
.//p[not(.//a[contains(concat(' ', normalize-space(./@class), ' '), ' x ')])]
Or if you want to continue building the XPath with xpath-builder:
var cssToXPath = require('css-to-xpath');
var xpathBuilderObject = cssToXPath.parse('p:not(:has(a.x))');
xpathBuilderObject = xpathBuilderObject.where(cssToXPath.xPathBuilder.text().equals('Some Text Content'));
// And get the XPath string
xpathBuilderObject.toXPath();
css-to-xpath parses css selectors using bo-selector and turns them into xpaths using xpath-builder
npm install css-to-xpath
BSD