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.
Why custom functions can't be used directly in assert?
I'm doing the following in a Sahi test script but it fails when calling a custom function:
But when I'm using an intermediate variable, it works:
From my point of view, this is neither practical nor intuitive.
Is it the way Sahi is designed or is there a special way to define and call user functions ?
function myFunction() {
return 10;
}
_assertTrue(myFunction()>0); // fails with error "myFunction is undefined"
But when I'm using an intermediate variable, it works:
var $myVar = myFunction();
_assertTrue($myVar>0); // works as expected
From my point of view, this is neither practical nor intuitive.
Is it the way Sahi is designed or is there a special way to define and call user functions ?
Answers
either put your function in <browser> tags or use an intermediate step.