Forum Discussion
3 Replies
- AlexKarasCommunity Hero
Hi Prabhjot,
Script units in TestComplete are not classes but just plain source code files. Depending on the script language that you use in your test project, you can declare classes and instantiate them in the same or another script unit. (Though this is not convenient in TestComplete due to some of its code editor specifics and thus is not recommended.)
Go through the https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/index.html help section. It should answer your question.
- Krishna_KumarContributor
Hi @prabhjot88singh ,
if you want to use the functions declared in unit1 to unit2 script files, you just have to give the "unit1" reference in "unit2"script file below the reference syntax.
reference syntax and example: Vbscript:
syntax - " 'USEUNIT [scriptName] "
example - (" 'USEUNIT Unit1 ") Javascript:
syntax - " //USEUNIT [scriptName] "
example - (" //USEUNIT Unit1 ")
please add this in the beganning of the script where you want to use the functions (in script "Unit2")please find the below snippet for accessing the fumctions:
syntax and example for accessing the function : Vbscript: syntax - " [FIleName].[FunctionName] " example - " Unit1.samplefunction() " Javascript: syntax - " [FIleName].[FunctionName] " example - " Unit1.samplefunction() "please let me know if i have answered yor answer or not
Hi prabhjot88singh,
Was the original issue resolved? Please let us know if the suggestions given here have helped.