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.

how to pass parameter values thro runtime

somisomi Members
edited November -1 in Sahi - Open Source
Actually am running a suite through commandline. The script i use has a funciton, can i be able to pass the parametes to the function during runtime(i.e) in command line???

if so, how????

Comments

  • No way to parametrize suites?
    Only by means of _callServer?
  • narayannarayan Administrators
    Currently, you cannot parametrize suites. If you could tell your requirements, I will add the needed features.
    Regards,
    Narayan
  • Something like

    httx://sahi.example.com/_s_/dyn/Player_auto2?file=" + file + "&startUrl=" + startUrl + "&p:paramName=03.04.2005"

    with the value "03.04.2005" accessible from scripts by means of

    date = _ARGS["paramName"]

    could be just fine.

    Suites could look in similar way:

    test1.sah /startPageForTest1.jsp p:paramName=03.04.2005

    Thank you,
    Alexander
  • Hi Narayan,

    Just a quick one to ask if you had a chance to implement this? It would be ideal for the current set of tests I have :)

    Cheers,
    Les.
  • narayannarayan Administrators
    There is another way to pass in a parameter which may not be the most elegant, but should work.

    Set a system property just before you invoke your suite, and then read the variable in your script like this:

    In your runsuite.bat
    SET MY_VAR=abcd
    

    In your script
    var $x = "" + java.lang.System.getenv("MY_VAR");
    _alert($x);
    

    Would that work for you?

    Or you can pass the param to Java using -D
    java -DMY_VAR=abcd net.sf...

    and access it using
    var $x = "" + java.lang.System.getProperty("MY_VAR");
    _alert($x);
    
  • Hi Narayan,

    Thanks for the response. Using environment variables or the Java -D flag would certainly work (thanks) and do make things easier. It would be ideal to be able to pass a parameter into each script in a suite, but what you suggested gets me a step closer to what I want and does help a lot :)

    Cheers,
    Les.
Sign In or Register to comment.