cancel
Showing results for 
Search instead for 
Did you mean: 

Script Routine Comments/Default values

New Contributor

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


tc_op_param.PNG

 

 

 

3 REPLIES 3
Community Hero

Re: Script Routine Comments/Default values

@tristaanogre Any ideas about this?

Community Hero

Re: Script Routine Comments/Default values

In JavaScript this works:

 

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

2019-01-31 13_34_42-Operation Parameters.png

 

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-...

 

 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Manager

Re: Script Routine Comments/Default values

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. 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
Top Kudoed Authors