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.

Sahi Scripting - Calling Java

edited November -1 in Sahi - Open Source
I read the post or tutorial on this topic, similarly when I tried using below code an getting error

java class "java.lang.String" has no public instance field or method named "toString". when executing code,
var $a = Packages.java.lang.Package.toString(2010);
_alert(a);
var $b = Packages.java.lang.String.toString(2010);
_alert(b);

am I missing some package details here?

Comments

  • narayannarayan Administrators
    Hi Bala,

    What are you trying to do? Convert an int to String? You can use
    var $a = "" + 2010
    for that.

    Regards,
    Narayan
  • Yes Narayan, I was trying to convert an int to String.

    var $a = ""+2010; it works

    thats nice trick.

    As all says, when thinking so hard on a problem we tend to go so crazy on logics, where we will never get to small easy stuff. :-)

    Thank you
This discussion has been closed.