Forum Discussion

mhowerto's avatar
mhowerto
New Contributor
6 years ago

Script Routine Comments/Default values

I'm curious if it is possible to add comments or default values for script routines.

 

Also if you can make your script routines use an enum so parameters could be picked from a dropdown similar to pmLower in the example. It looks like this should be possible but I just can't find how to do it.

I have a function like:

def generic_function(param1="A String", 
                     param2=42, 
                     param3=[1,2,3], 
                     param4={"key1":"val1", 
                             "key2":"val2"}):
    # do the thing

but when I go to run script routine in the keyword test it just defaults all the parameters to None


 

 

 

3 Replies

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      In JavaScript this works:

       

      function defaultParams(parm1 = 'test', param2 = 3){
          Log.Message(parm1)
          Log.Message(param2)
      }

       

      So, this tells me that the problem is not in TestComplete necessarily.  The code you posted is in Python.  I'm not 100% certain what the proper answer is for Python script.  But I do know that, at least default "basic" data types work.  An enumerated data like a key/value pair... I don't think that will work.

       

      If you WANT to go that route...instead of a script routine, create a Keyword Operation Script Extension with a custom User Form to prompt for parameters where you can set up the pre-defined values and drop downs.  See https://support.smartbear.com/testcomplete/docs/working-with/extending/script/creating/keyword-test-operations/index.html

       

       

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi mhowerto,

     

    It is strange that the same behavior works for JavaScript routines, and it doesn't work for a Python one.

    I've reported this behavior to our R&D team.