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.
Call Java code from controller7.js using Rhino
Hi all,
I added a new button to the controller to perform some actions on steps, I want to execute a java code when I press the button I've created. Following this guide: ht tp://sahi.co.in/w/sahi-scripting-calling-java I tried to call my Java java code in the controller7.js as follows:
This doesn't seem to work: "Packages" is not recognized when I click on the button. However, if I put my same code in a .sah script and I run that script, java code is executed perfectly.
What do I have to add to get my java code executed directly from controller.js using Rhino?
Many thanks in advance.
Cheers,
mng.
OS:xp
Browser:All
Sahi:V3.5
I added a new button to the controller to perform some actions on steps, I want to execute a java code when I press the button I've created. Following this guide: ht tp://sahi.co.in/w/sahi-scripting-calling-java I tried to call my Java java code in the controller7.js as follows:
function parser2() {
var parser = new Packages.p.Parser("D:\\Sahi\\userdata\\scripts\\Steps1.sah");
var $list = parser.getFunctions();
_alert( $list.size());
for (var $i=0; $i<$list.size(); $i++){
_alert( $list.get($i));
} }
This doesn't seem to work: "Packages" is not recognized when I click on the button. However, if I put my same code in a .sah script and I run that script, java code is executed perfectly.
What do I have to add to get my java code executed directly from controller.js using Rhino?
Many thanks in advance.
Cheers,
mng.
OS:xp
Browser:All
Sahi:V3.5
Comments
Controller is not exposed to rhino engine so you should not be using this.
Instead you can include it in .sah file and run it through the sahi script.
Regards
Sumitra
Is there a way to make Controller exposed to the rhino engine? if yes, kindly help with steps to get this done.
I already tried with working with .sah files and run it as a script, that works as I said, but this is not useful for me as far as I have to pass data I get with my Java code (in my code: the steps in the list) to a combo-box I've created in the controller.
Many thanks for help, this is quite urgent.
Cheers,
mng.
I did a research on the issue. I'm noticing that the lib.js file is covered by Rhino since it calls some Packages.XXX classes.
My question is simple: what makes the difference between lib.js and another .js file of Sahi so that lib.js is covered by Rhino and others not?
What should I add to make a custom .js file covered and interpreted by Rhino ?
Please help.
Thanx,
mng.