Forum Discussion
If you responded with "we use Execute keyword to send these parameters to another script units. which looks like Function TC_Des_Datasheet(PName, PValue, Data, TestcaseDesr, Testcaseno, ProcessName)" then we can understand for those that don't have VBScript experience.
There's no Execute keyword in Python. If you want to pass parameters to a function in another file in Python, then do:
Python’s built-in exec() function allows you to execute arbitrary Python code from a string or compiled code input.
Thank you for your response.
As you suggested, we tried to implement your solution, but we are not able to run the Testcomplete as we do in VBScript.
Please find below for the actual code:
PyDriverScript Script Unit - i.e., File 1 starts,
import PyFun
def RunOrderSheet():
TC_NO_Runorder = RunOrderSheetCelVal.Value["Tc No"]
Execution = RunOrderSheetCelVal.Value["Execute"]
Datasheet_Flag = RunOrderSheetCelVal.Value["Datasheet_Flag"]
ModuleName_runorder = RunOrderSheetCelVal.Value["ModuleName"]
TestcaseDesr = RunOrderSheetCelVal.Value["Descirption"]
if Execution == "YES":
import PyDriverScript
PyDriverScript.DataSheet(TC_NO_Runorder,ModuleName_runorder,Datasheet_Flag,TestcaseDesr)
#-----------------------------------------------
def DataSheet(TC_NO_Runorder,ModuleName_runorder,Datasheet_Flag,TestcaseDesr):
TC_NO_Datasheet = DBVar1.value["Tc No"]
TC_Description_Datasheet = DBVar1.value["Tc Descirption"]
ModuleName_Datasheet = DBVar1.value["ModuleName"]
if TC_NO_Datasheet == TC_NO_Runorder and ModuleName_Datasheet == ModuleName_runorder:
Property_Name = DBVar1.value["Propertyname"]
Property_Value = DBVar1.value["Propertyvalue"]
Data = DBVar1.value["Data"]
ModuleName_Datasheet = DBVar1.value["ModuleName"]
Testcaseno = DBVar1.Value["Tc No"]
Process_Name = DBVar1.value["Processname"]
Testlink_Id = DBVar1.value["Testlinkid"]
str = "toSmartBear2.MTE_Textbox_One_level(\"TC_Description_Datasheet\Property_Name\Processname\")"
exec(str)
DBVar1.Next()
PyDriverScript Script Unit - i.e., File 1 Ends.
#-----------------------------------------------
Actual PyFun Script unit - i.e. File 2 starts,
import PyDriverScript
#def MTE_Textbox_One_level():(Property_Name,Property_Value,Data,ModuleName_Datasheet,TestcaseDesr,Testcaseno,Process_Name,Testlink_Id)
#Log.Message(Process_Name)
#Code = Sys.Process(Process_Name).Find(Property_Name,Property_Value,500)
#Code.Keys(Data)
#Log.Message (Data)
#PyFun Script unit-i.e., File 2 ends.
#--------------------
If we run the PyDriverScript i.e. File-1, without commenting the PyFun i.e. File-2, then
We got a NameError, it says, name 'Process_Name' is not defined in MTE_Textbox_One_level function.
Then if we run file-1 again with File-2 commented, then in the line: exec(str) Python Run time error occurred; Error details from Testcomplete log: AttributeError 'module' object has no attribute 'MTE_Textbox_One_level'.
We just followed your suggestion but could not run the test.
Thanks.
Related Content
Recent Discussions
- 9 hours ago
- 7 days ago
- 10 days ago