18 January 2026:


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 Sahi script

SuparnaSuparna Members
edited November -1 in Sahi - Open Source
Call java code from Sahi scripts (Steps followed) :

1. Created folder name called Jarfiles in sahi path(c:\sahi).
2. Copied Class file of java code, and created Jar file.
3. In sahi.bat “ set SAHI_EXT_CLASS_PATH=%SAHI_HOME%\Jarfiles\jarex.jar” code added.
[and also tried by coping jarex.jar file to extlib folder and SAHI_EXT_CLASS_PATH=%SAHI_HOME%\ extlib \jarex.jar]
4. I am calling java code “var strJava = Packages.Testing.Excel.CreateExcel();”
5. I am getting error “Cannot call property CreateExcel in object [JavaPackage Testing.Excel]. It is not a function, it is "object". “

Kindly provide solution for this problem.

Comments

  • Suparna,

    To create a new object do this:
    var $strJava = new Packages.com.example.ClassName(); 
    $strJava.methodName();
    
  • herseeingherseeing Members
    edited November 2011
    Why i created a new object like above and got an error msg: TypeError: [JavaPackage com.docsite.webapp.generical.TestJava] is not a function, it is object.
    could you help me out?
Sign In or Register to comment.