i have written two modules in python "Sample.py" and "GenericFunctions.py" from "Sample.py", iam calling a function
present in "GenericFunctions.py" but i am not able to call that function getting error as "AttributeError: 'module' object has no attribute 'fn_ElseLog'"
Code in Sample.py:
import GenericFunctions
def sampleee():
g_TCaseID="SD1233"
g_TCDescription="Login"
g_TestData="hi"
g_Result="Fail"
g_Remarks="testing"
g_TargetEnvironment="S1"
g_TargetSystem="Legacy"
g_TargetRegion="EU"
x = GenericFunctions.fn_ElseLog(g_TCaseID, g_TCDescription, g_TestData, g_Result, g_Remarks)
sampleee()
Code in GenericFunctions.py:
def fn_ElseLog(g_TCaseID, g_TCDescription, g_TestData, g_Result, g_Remarks):
print "entered in ElseLog Function"
Output= fn_Output(g_TCaseID, g_TCDescription, g_TestData, g_Result , g_Remarks)
print ("Testcase"+"'"+g_TCDescription+"'"+"execution completed"+"'"+g_TargetEnvironment+"-"+g_TargetRegion)
def fn_Output(p_TCaseID, p_TCDescription, p_TestData, p_Result , p_Remarks):
OutputSheet=""
OutputSheet="\Test"+"_"+g_TargetEnvironment+"_"+g_TargetSystem+"_"+g_TargetRegion+".xlsx"
OutputPath=r"C:\Users\u304080\Desktop\PlayAround\Shakedowns\OutputResultFiles"
#objExcel1 = win32.gencache.EnsureDispatch('Excel.Application')
Outputfile=os.path.exists(OutputPath+OutputSheet)
if Outputfile==True :
print('Output file is present')
else:
print('Output file is not present')
return
objExceloutput = win32.gencache.EnsureDispatch('Excel.Application')
#excel.DisplayAlerts = False
objoutputworkbook = objExceloutput.Workbooks.Open(OutputPath+OutputSheet)
objSheetOutput = objoutputworkbook.Sheets(1)
OutputRowCount =objSheetOutput.UsedRange.Rows.Count
print "OutputRowcount" , OutputRowCount
objSheetOutput.Cells(OutputRowCount+1,1).Value=p_TCaseID
objSheetOutput.Cells(OutputRowCount+1,2).Value=p_TCDescription
objSheetOutput.Cells(OutputRowCount+1,3).Value=p_TestData
objSheetOutput.Cells(OutputRowCount+1,4).Value=p_Result
objSheetOutput.Cells(OutputRowCount+1,4).Font.Bold = True
if p_Result=="Pass":
objSheetOutput.Cells(OutputRowCount+1,1).Font.ColorIndex = 10
else:
objSheetOutput.Cells(OutputRowCount+1,1).Font.ColorIndex = 3
objoutputworkbook.SaveAs(OutputPath)
objSheetOutput=None
objoutputworkbook=None
objExceloutput.Quit()
objExceloutput=None
Can you guys show me a solution for this?