Forum Discussion

ilija_panov's avatar
ilija_panov
Contributor
15 years ago

calling script function in code expression parameter in keyword test ?

Hi,



I have started working with JScript in TC and my first task was to write a function for formating a string variable taken from an excel file in the datadriven  input of a keyword test.



The idea is to apply this  function i have defined in a JScript unit under \scripts:




function index(account)

{

  var index;

  var regEx ;

  regEx = /(\d{1,1})/g, "|[$1]";

  index = "[0]" + regEx.replace(account);

  return index; 

 } 



The datadriven input variable in a keyword test which looks like  "KeywordTests.AAC.Variables.coa("account")". Any ideas how to this  in the keyword test Edit Parameter window (maybe Code Expression), or is it neccesary to convert the keyword test to a script as well?



Thanks in advance,

    Ilija

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Something you can do is call your function as is as a script routine call in your keyword test.  There is then an option when setting parameters to use "Last Operation Result".  Since your function returns a value, that would be the "Last Operation Result" and will feed into your parameter as such.