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.
Reference Error
Hi All,
i have a problem while using JavaScript function within sahi
here is my piece of code as follows
<browser>
function Generaterandom()
{
var randomnumber = new Date();
randomnumber = parseInt(randomnumber/1000);
return randomnumber;
}
</browser>
_set($RandomNumber, Generaterandom());
_debug(Generaterandom());
from my end it looks fine but it giving me an error as following below
_sahi.setServerVar('\$RandomNumber', Generaterandom());
ReferenceError: Generaterandom is not defined
so anybody can tell where my code goes wrong and why i am getting this error
any solution will be appreciate.
thanks in advance
warm Regards,
DInesh.k
i have a problem while using JavaScript function within sahi
here is my piece of code as follows
<browser>
function Generaterandom()
{
var randomnumber = new Date();
randomnumber = parseInt(randomnumber/1000);
return randomnumber;
}
</browser>
_set($RandomNumber, Generaterandom());
_debug(Generaterandom());
from my end it looks fine but it giving me an error as following below
_sahi.setServerVar('\$RandomNumber', Generaterandom());
ReferenceError: Generaterandom is not defined
so anybody can tell where my code goes wrong and why i am getting this error
any solution will be appreciate.
thanks in advance
warm Regards,
DInesh.k
Tagged:
Comments
When i tried to run your sahi script code, its not throwing any error for me and its running fine
can you specify some more information,
1.Which OS you are using?
2.Which version of Sahi?(check for the build date at the top right corner of the sahi controller that you are using.)
3.In Which browser you are testing?
Thanks,
Venky.
Try commenting <browser></browser> tags and then run it again. I think u won't need them as ur function is not acting on the page's DOM.
Regards,
Pankaj
thanks for your reply ,
i have sorted this issue ,it was not in the above function , this error belong to another function which i have written . it is very difficult to identify error in sahi i have to check my all function which i have written and i identify some syntax flaws so i correct it and move forward .
warm Regards,
DInesh.k
What editor do you use to edit Sahi files?
It is easy to catch these errors if you use Eclipse or some other editor which provides syntax highlighting and bracket matching.
Regards,
Narayan
i am using Editplus 2 editor for my script .
can you suggest me which one will be best editor to recognized error as soon as possible
because it take lots of time to find the error in Editplus 2 Editor
Thanks in Advance,
Warm Regards,
DInesh.k