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 do I call Java Code from scripts / Broken links
How do I call Java Code from Sahi Scripts ?
I need to read a properties file and it looks much easier to do it in Java and then call the same from sahi scripts.
I saw a link for this page ( ( http://sahi.co.in/w/invoking-java-in-rhino) but this link is broken.
thanks,
Hari
I need to read a properties file and it looks much easier to do it in Java and then call the same from sahi scripts.
I saw a link for this page ( ( http://sahi.co.in/w/invoking-java-in-rhino) but this link is broken.
thanks,
Hari
Tagged:
Comments
Where was the broken link present?
Can only static java methods be called ?
Will what is given in this page (http://www.mozilla.org/rhino/ScriptingJava.html ) on Rhino / Java work directly in Sahi ?
Or do I need to wrap usages of Java like in the above page in <browser> </browser> tags in the script ?
If so and I write some custom Java code where would I need to place them ?
Is it in the browser's JRE or in Sahi Proxy's classpath ?
I don't remember the page where the broken link was present right now.
I'll update this post with the link soon.
thanks,
Hari
Regards,
Narayan
I think adding more examples like these to the Sahi Documentation will help adoption!
Should it be added to the Sahi Proxy classpath or is it the browser's JRE ?
You should add it to the Sahi Proxy classpath. Note that, for custom classes you will need to use "Packages." prefix.
eg.
var obj = new Packages.com.company.path.MyClass()
Regards,
Narayan
I couldn't find where I saw the broken link for http://sahi.co.in/w/invoking-java-in-rhino but I saw another broken link on this page :
http://sahi.co.in/w/_callserver ( Link to http://sahi.co.in/w/w/adding-jars-to-sahis-classpath is broken )
I'll update this thread when I find it.
or
I would like to read my Properties File Once and store it to an object then get properties from the object.
Right now I'm having code like
in a file which I include in my scripts and then in my scripts I use
getProperty("my.propery.key");
This does't work. What am I doing wrong ?
In the second part of your question, you have not assigned
var $testsuite_properties = readPropertiesFile();
before
getProperty("my.propery.key");
but now got it working!
Thanks for the clarification..
I don't understand about "Add it to the Sahi Proxy classpath", and the link under "Add it to Sahi’s classpath:" in http://sahi.co.in/w/_callserver is removed, can you kindly to reply me?
Thanks in advance,
Fion