How to execute a Python routine in Testcomplete
We use VBScript for Automating a Desktop or window application.
And now, we have to change the scripting language into Python.
In the VBScript framework: Driverscript is the main script unit, in this only everything is given.
Overview of the framework:
We get the object values of the application from Excel sheet.
How the values are being processed is defined in the Driverscript.
In the Driverscript, there are 2 routines, namely: Runordersheet and Datasheet
Runordersheet is responsible for which test case or script needs to be run, like value is given as Yes or No
Datasheet has the actual actual Test cases, where the steps and expected results are developed.
So, once we Run the Testcomplete, it starts from Driverscript then goes to Runordersheet routine in that if Execution values is Yes then it goes to the Datasheet routine, here if the condition is true then it goes to the Execute line with collective data (Execute TC_Des_Datasheet&""""&PName&""""&","&""""&PValue&""""&","&""""&Data&""""&","&""""&TestcaseDesr&""""&","&""""&Testcaseno&""""&","&""""&ProcessNam&""""&","&"""") and actual Automation event starts in: function Script Unit where the Automation events are developed as an individual routine.
In this function script unit: handling the textbox as Keys method, button as click method and whichever actions need to be performed is available as a routine.
Sample Driverscript code:
Sub Runorder_Sheet
TcNo_Runorder = Runorder_Sh.Value("TCNo")
ExState = Runorder_Sh.Value("ExeState")
DSNam = runorder_Sh.Value("Datasheet_Nam")
TestcaseDesr = runorder_Sh.Value("Des")
If Execution = "YES" Then
call Data_sheet(TcNo_Runorder,ModuleName_runorder,DSNam,TestcaseDesr)
end if
End sub
Sub Data_sheet(TcNo_Runorder,ModuleName_runorder,DSNam,TestcaseDesr)
TCNO_Datasheet = Datasheet.value("TCNo")
TC_Des_Datasheet = Datasheet.value("TCDes")
If TCNO_Datasheet = TcNo_Runorder and ModNam_Datasheet = ModuleName_runorder Then
PName = Datasheet.value("Pname")
PValue = Datasheet.value("Pval")
Data = Datasheet.value("Data")
Testcaseno = Datasheet.Value("TcNo")
ProcessNam = Datasheet.value("Processname")
Execute TC_Des_Datasheet&""""&PName&""""&","&""""&PValue&""""&","&""""&Data&""""&","&""""&TestcaseDesr&""""&","&""""&Testcaseno&""""&","&""""&ProcessNam&""""&","&""""
End if
End sub
Sample Function code:
Sub MTE_Textbox_Two_level(Property_Name,Property_Value,Data,ModuleName_Datasheet,TestcaseDesr,Testcaseno,Process_Name,Testlink_Id)
arr=split(Property_Value,",")
arr1=split(Property_Name,",")
Set checkpoint=Sys.Process(Process_Name).Find(arr1(0),arr(0))
Set child = checkpoint.Find(arr1(1),arr(1))
child.Keys(Data)
End sub
Sub MTE_Button_Two(Property_Name,Property_Value,Data,ModuleName_Datasheet,TestcaseDesr,Testcaseno,Process_Name,Testlink_Id)
arr=split(Property_Value,",")
arr1=split(Property_Name,",")
Set checkpoint=Sys.Process(Process_Name).Find(arr1(0),arr(0))
Set child=checkpoint.Find(arr1(1),arr(1))
child.click
End sub
'-------------------
Above mentioned every line of code is developed with VBScript, and the same code we have to change into PythonScript.
Almost we are completed but in the Execute line of Datasheet routine of Driverscript Script Unit, we are stopped, don't know how to proceed further.
As in the below execute code of VBScript, how we can execute and pass the code in Python.
Execute TC_Des_Datasheet&""""&PName&""""&","&""""&PValue&""""&","&""""&Data&""""&","&""""&TestcaseDesr&""""&","&""""&Testcaseno&""""&","&""""&ProcessNam&""""&","&""""
or any better idea to proceed further with Python script.
Please let me know if you have any query.
Thanks.