selenium - Which XPath version is supported in PhantomJS? -


i'm using selenium phantomjs. how can find out version of xpath used in phantomjs?

you can directly check whether specific functions supported or not. example, boolean() provided xpath 1.0, abs() provided xpath 2.0.

phantomjs 1.x & 2.0 supports xpath 1.0.

full script:

var page = require('webpage').create();  console.log(json.stringify(page.evaluate(function(){     var b = -1, body = -1, abs = -1;     try{         b = document.evaluate("boolean('a')", document, null, xpathresult.boolean_type, null).booleanvalue;     }catch(e){}     try{         body = !!document.evaluate("//body", document, null, xpathresult.first_ordered_node_type, null).singlenodevalue;     }catch(e){}     try{         abs = document.evaluate("abs(-10.5)", document, null, xpathresult.number_type, null).numbervalue;     }catch(e){}     return {         "boolean": b,         "body": body,         "abs(-10.5)": abs,     }; }), undefined, 4)); phantom.exit(); 

output:

{     "abs(-10.5)": -1,     "body": true,     "boolean": true } 

Comments

Popular posts from this blog

python - Installing PyDev in eclipse is failed -

PHP OOP-based login system -

c# - Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment -