I am trying to get XPath to work with PhantomJS 1.9.2:
var getElementsByXPath = function(xPath) { return document.evaluate( xPath, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); }; var root = getElementsByXPath("//div").iterateNext();
This is done when the page loads and always returns null, while querySelector works correctly:
var divs = page.evaluate(function(s) { return document.querySelector(s); }, 'div');
Did I miss something in this particular XPath example for evaluation?
xpath phantomjs
John doe
source share