18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
JSERROR while executing code using playback
Hi Narayan
While I am executing following code in controller it runs without throwing any exception and gives proper output
"JSERROR
ReferenceError: "DOMParser" is not defined. "
Sahi version V2
Firfox version "3.6.8'
OS windows 2000
While I am executing following code in controller it runs without throwing any exception and gives proper output
var $parser = new DOMParser()
$xAxisName = $parser.parseFromString(eval("DIGITE.App.Dashboard.instance.charts[10001].chartData.data").toString(),"text/xml").getElementsByTagName("graph")[0].getAttribute("xAxisName");
_alert($xAxisName);
but while executing same code using playback, its throw an error"JSERROR
ReferenceError: "DOMParser" is not defined. "
Sahi version V2
Firfox version "3.6.8'
OS windows 2000
This discussion has been closed.
Comments
You are right about DOMParser being available only on the browser, and hence why Ganesh's code did not work. But unfortunately you can use _set only for objects which can be serialized to JSON objects (some objects may fail to be serialized).
A better way to do this would be to get the xml string using _set, and then use new XML() to parse the xml.
var $data;
_set($data, DIGITE.App.Dashboard.instance.charts[10001].chartData.data.toString());
_alert($data);
var $dom = new XML($data);
_alert($dom.descendents("graph")[0].xAxisName);
Accessing elements is different from DOM parser, and is defined by E4X. (Google E4X for more details and have a look at this post: http://blog.sahi.co.in/2009/06/parsing-xml-in-sahi-scripts.html)
Regards,
Narayan
Don't use XML object in the browser tag. Use it as I have specified in my post. XML is not available on the browser.
I have rectified the blog link. Thanks for pointing out.
Regards,
Narayan
Regards,
Narayan