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.
Problem assigning value returned by getAttribute to a variable.
Hi,
I am trying to extract the value of innertext of an element using getAttribute method. It works as long as I evaluate the expression using the "Evaluate Expression" in Sahi Controller. But if I try to use the same through a script it throws an error saying "'_sahi._byId(...) is null or not an object".
Can you please suggest any workaround for this.
Sample code is below:
var $x = _byId("id").getAttribute("innerText");
_alert($x);
same works fine if used as:
_alert(_byId("id").getAttribute("innerText"));
Looking forward for suggestions.
Regards,
Pankaj.
I am trying to extract the value of innertext of an element using getAttribute method. It works as long as I evaluate the expression using the "Evaluate Expression" in Sahi Controller. But if I try to use the same through a script it throws an error saying "'_sahi._byId(...) is null or not an object".
Can you please suggest any workaround for this.
Sample code is below:
var $x = _byId("id").getAttribute("innerText");
_alert($x);
same works fine if used as:
_alert(_byId("id").getAttribute("innerText"));
Looking forward for suggestions.
Regards,
Pankaj.
Comments
I also tried to assign the value returned by _getText to a variable but the same problem persists. Any help would be welcome.
Got it done sir. Thanks for your valuable guidance.
Regards,
Pankaj.
Most of the problems I face are due to page dependent variables. I have gone through the text that you have suggested. However I dont seem to have got hold of the subject. Please explain it in a simpler way considering i am totally new to sahi and jscript.
Thanks and Regards,
Pankaj Kumar.