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.
Arrays with Sahi OS
Hello all,
I'm having a lot of trouble working with arrays in sahi. In vanilla JS, I can use things like pop() and array.forEach to do all sorts of useful things with arrays. Is it possible to use things like that in sahi? I tried using _call and _eval to run JS through the sahi controller without much luck, and I couldn't find anything in the api that seems to do things like that with normal sahi code.
Thanks!
I'm having a lot of trouble working with arrays in sahi. In vanilla JS, I can use things like pop() and array.forEach to do all sorts of useful things with arrays. Is it possible to use things like that in sahi? I tried using _call and _eval to run JS through the sahi controller without much luck, and I couldn't find anything in the api that seems to do things like that with normal sahi code.
Thanks!
Comments
Yes, you can perform all required actions with arrays using Sahi. Sahi script is based on javascript. So you can directly use the looping conditions for the arrays.
For example:
var $arr=[10,20,30];
$arr=$arr.pop();
_log($arr);
//will perform the pop operation on the array and returns the last element from the array.
Similarly, you can also loop through the array as below.
var $arr=[10,20,30];
for(var $i=0;$i<$arr.length;$i++){
_log($arr[$i]);
}
You can use the _call or _eval API for any expression which needs to be evaluated on the browser DOM.
Hope this helps!
Thanks and regards,
Sita