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.

Trying to access the Jar using Sahi pro and getting reference error

anandkiran2007anandkiran2007 Members
edited February 2013 in Sahi Pro
Below is my Java code which is convered into jar and placed in extlib and the same path has been configure in sahi dashboard.bat

import java.util.Calendar;
import java.text.SimpleDateFormat;

public class GenerateDate
{
public String getDate()
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat formatter= new SimpleDateFormat("dd/MM/yyyy");
String dateNow = formatter.format(currentDate.getTime());

return dateNow;
}
}


And below is the sahi script which was used to access the method in the jar

var $d = new GenerateDate();
var $date = $d.getDate();
_alert($date);

But below error was returned when the above sahi scripts was executed

ERROR [110 ms] [01:40:56.416]
ReferenceError: "GenerateDate" is not defined.

Answers

  • Can you any one help me where I am going wrong.. Because I have lots of scripts which needs to converted into jar and utilize them in sahi scripting. This is primary step I just tried
  • I have referred the following discussion thread
    http://sahi.co.in/forums/discussion/3315/how-to-use-jar-file/p1,
    but still ended up in vain
  • Hi Ashwini,

    The above snippet works but I want to derive Past and Future dates when i tried the below code it throws an error


    var $day = new java.text.SimpleDateFormat("dd/MM/yyyy");
    var $currentDay = $day.format(new Date() + 1);
    return $currentDay;

    ERROR [0 ms] [03:35:46.705]
    Wrapped java.lang.IllegalArgumentException: Cannot format given Object as a Date


    Any idea how to achieve this..
Sign In or Register to comment.