prasant87
13 years agoNew Contributor
Passing Object Full Name through Excel
Hi,
I am trying to implement an excel data driven test script and getting an error while performing any operation on objects passed from excel sheet.
Below is a edited code and I will explain the concept and error as commented line -
Sub ExcelData
Dim Obj,excel,workbook,sheet,var,Path
Path="D:\Project\Testcases.xls"
Set excel=CreateObject("Excel.Application")
excel.visible = True
Set workbook=excel.workbooks.open(Path)
Set sheet=workbook.worksheets("Test_Script")
Set Obj=sheet.cells(4,"C") ' Excel sheet cell contains Full Name of the object copied after spying
Obj.Click 'This line gives an error
Set Obj=nothing
Set sheet=nothing
Set workbook=nothing
Set excel=nothing
End Sub
Instead of code line
Set Obj=sheet.cells(4,"C") ' Excel sheet cell contains Full Name of the object copied after spying
Obj.Click 'This line gives an error
if I use below hard coded script it works -
Set Obj=Obj_Full_Name_Spied_using_Test_Complete
Obj.Click
But, I want to pass Object Property Name as parameter and then generalize the tests based on that.
Your immediate response is highly appreciated.
P.S. Attached is the error message.
Thank you
Prasant
I am trying to implement an excel data driven test script and getting an error while performing any operation on objects passed from excel sheet.
Below is a edited code and I will explain the concept and error as commented line -
Sub ExcelData
Dim Obj,excel,workbook,sheet,var,Path
Path="D:\Project\Testcases.xls"
Set excel=CreateObject("Excel.Application")
excel.visible = True
Set workbook=excel.workbooks.open(Path)
Set sheet=workbook.worksheets("Test_Script")
Set Obj=sheet.cells(4,"C") ' Excel sheet cell contains Full Name of the object copied after spying
Obj.Click 'This line gives an error
Set Obj=nothing
Set sheet=nothing
Set workbook=nothing
Set excel=nothing
End Sub
Instead of code line
Set Obj=sheet.cells(4,"C") ' Excel sheet cell contains Full Name of the object copied after spying
Obj.Click 'This line gives an error
if I use below hard coded script it works -
Set Obj=Obj_Full_Name_Spied_using_Test_Complete
Obj.Click
But, I want to pass Object Property Name as parameter and then generalize the tests based on that.
Your immediate response is highly appreciated.
P.S. Attached is the error message.
Thank you
Prasant