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.
Can I access Sahi functions as first class objects?
Hi,
In order to implement some more robust features into the automation and testing suite I'm working on, it would be really great if I could pass some of Sahi's built in functions around to various methods. I know I could wrap all the functions inside of my own, but from a convenience standpoint it would be awesome if I could do something like:
However, I get an error that _div is undefined. I understand this is likely due to how Sahi parses the script and what's actually processed in the browser and what's actually processed in the proxy.. However, I thought I would ask if there is a simple way to do this other than the tedious action of wrapping all the sahi built-ins..? Is there a way to truly access the _div function as a first class object? I see in the parsed scripts it gets translated to _sahi._div but I tried accessing it like that and it didn't work either =/. Help!
Additions:
I've tried just putting _sahi._div in the controller's 'Evaluate expression' tab, and it correctly prints the function.. but it won't let me assign it to a variable
In order to implement some more robust features into the automation and testing suite I'm working on, it would be really great if I could pass some of Sahi's built in functions around to various methods. I know I could wrap all the functions inside of my own, but from a convenience standpoint it would be awesome if I could do something like:
function demo($accessorFunction){
return $accessorFunction({className:"/bla/"}, _in($something));
}
var $divFunction = _div;
var $aDivWithClassBlaInsideOfSomething = demo($divFunction);
However, I get an error that _div is undefined. I understand this is likely due to how Sahi parses the script and what's actually processed in the browser and what's actually processed in the proxy.. However, I thought I would ask if there is a simple way to do this other than the tedious action of wrapping all the sahi built-ins..? Is there a way to truly access the _div function as a first class object? I see in the parsed scripts it gets translated to _sahi._div but I tried accessing it like that and it didn't work either =/. Help!
Additions:
I've tried just putting _sahi._div in the controller's 'Evaluate expression' tab, and it correctly prints the function.. but it won't let me assign it to a variable