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.
How to convert String to a Function?
Hi,
I am new for this Tool, I am trying to build a framework for my application. Could you please guide me...
Excel file having following details:
KeywordAction PropertyNames Values
set xxxx Help
setPwd xxxx xxxxxx
clickButton Submit
...
In the above details, "KeywordAction" column having UserDefined Functions.
i am able to retrieve the functions, however i am facing a problem i.e.
$fName = $rs[$i]["KeywordAction"]
$fName($rs[$i]["PropertyNames"], $rs[$i]["Values"]);
Here it's shown error message as "JSERROR TypeError: $cm is not a function, it is string."
But in QTP, I can do this as follows:
fname = datatable.value("KeywordAction","SheetName")
propName = datatable.value("PropertyNames","SheetName")
vals = datatable.value("Values","SheetName")
execute fname propName, vals
if I write like this, QTP will identify "fname" as function and run.
Is there any Functiion/Method in SAHI?
Thanks in Advance.
Thanks & Regards,
Tulasi.
I am new for this Tool, I am trying to build a framework for my application. Could you please guide me...
Excel file having following details:
KeywordAction PropertyNames Values
set xxxx Help
setPwd xxxx xxxxxx
clickButton Submit
...
In the above details, "KeywordAction" column having UserDefined Functions.
i am able to retrieve the functions, however i am facing a problem i.e.
$fName = $rs[$i]["KeywordAction"]
$fName($rs[$i]["PropertyNames"], $rs[$i]["Values"]);
Here it's shown error message as "JSERROR TypeError: $cm is not a function, it is string."
But in QTP, I can do this as follows:
fname = datatable.value("KeywordAction","SheetName")
propName = datatable.value("PropertyNames","SheetName")
vals = datatable.value("Values","SheetName")
execute fname propName, vals
if I write like this, QTP will identify "fname" as function and run.
Is there any Functiion/Method in SAHI?
Thanks in Advance.
Thanks & Regards,
Tulasi.
Tagged:
This discussion has been closed.
Comments
Use eval(string) to convert it into a function (or whatever that string represents).
In your case, it would be
$fName = $rs[$i]["KeywordAction"];
var $fn = eval($fName); // converts to function.
$fn($rs[$i]["PropertyNames"], $rs[$i]["Values"]);
Regards,
Narayan