Ask a Question

Passing parameters from Organize Tests to test script


Passing parameters from Organize Tests to test script



How to pass parameters from a script test using Parameters column present in Organize Tests view and then read that value within the test script?

For example: I want to pass paramenters like browser value (such as Edge) and read this value into a variable within my test script and launch the specified browser accordingly.


Is this possible? If yes, please explain how? Thanks!

Community Hero

Yes, it can be done.


You have to change the signature of your script function to accept a parameter e.g.


function StartBrowser(browsername, url)
  //This following logic handles when your call to the function doesn't supply a value for the first parameter
  if(browsername==undefined || browsername==null){
   browsername = 'iexplore'
if(url == undefined || url==null{
  url ='';
 //start the browser - can't recall the command exactly for this, since it's one of my tested applications so I don't need to worry

function CallStartBrowser(){

If you drag your StartBrowser script into your keyword designer, you will be able to double click the parameters column.  This will bring up an operation parameters box where you can specify the details

Standard syntax disclaimers apply

Hi Rudolf,


Thanks for your reply! But, I am somehow unable to figure out how to do this: If you drag your StartBrowser script into your keyword designer, you will be able to double click the parameters column.  


Still new to the tool, so could you provide a screenshot or elucidate more on the step please?

The best place to get some help would be the TC help files. From your TC application open help (F1) and look up "Run script routine operation" You can also look at "Checking operation Result" these two work together to get to what you are trying to achieve

There are two ways of getting a script to run from your KWT.

1. Select the "Run Script Routine" operation, select the script you want to run, then complete the operation parameters
2. Take the script object from the project workspace->project explorer and drag it into the KWT window. From here it is the same as "Run Script Routine"

Run script routine.JPG

Select Script.JPG

Enter operation parameters.JPG

Final result.JPG


Standard syntax disclaimers apply

Yes, I do see the option to Add Parameter in the KWT pane now. But, actually I am looking for Adding Parameter to Test Script Units itself, not to Keyword Tests as shown in your screenshot. Can we do it?

I must be honest and say that I don't quite understand how that is not addressed by the initial code I posted.  Perhaps you are trying to return the browser as an object from another script call ?  In that case, replace




return Browsers.Items(browsername,url);


Then in your calling function, rather than



var newBrowser = StartBrowser('edge','');


Standard syntax disclaimers apply

I'm sorry to have caused any confusions. Let me explain my requirement with examples.


I have a sccript routine named - loginToWebApp() - This script routine has the code to open the browser and login to the web application. 


I have added the above script routine as a test item in Organize tests and I am running it.

Currently I have defined a variable named browser in the class which has loginToWebApp() as shown below:


let browser = "Edge";


Then I am reading this value and opening the browser.


What I would like to do is add this as a parameter in the "Parameters" column and then read it from there instead of reading from the global variable. Is this possible?

Or can we only add your code as a parameter within Keyword tests alone and not for a script routine test?


PFA screenshot. As you can see I have a test item named Login and I want to provide the browser name as parameter in the parameter column. Then substitute the value within the Login Test script like this: browser = [browser name read from parameter column]


You can use a function in script with a parameter/mutiple parameters.  Create the function in the initial post.  Now drag that script unit into your window.  All the functions in your script will be added.  Remove the ones you don't want, then update the parameters as required - just like setting in in a KWT. Alternatively, add new test item.  Click elipses in the test column and select the script.  This process looks the same as "Run Script" from within a KWT


Added Script.JPG




Standard syntax disclaimers apply

Thank you! I will try that out and let you know by tomorrow 🙂 

Champion Level 2

@nish_b wrote:

I'm sorry to have caused any confusions. Let me explain my requirement with examples.


I'll hijack your parameter discussion for a moment to urge everyone once again to post as much detail as possible in your FIRST post.   Doing this makes it much easier on everyone.  You don't have to wait for us to ask more questions to figure out what you are really trying to do and we can give you a quicker answer that won't be something that you've already tried.  


@nish_b other posters do this every day, it's not just you!  Thanks for the teaching opportunity!   🙂

Showing results for 
Search instead for 
Did you mean: