This is a migrated thread and some comments may be shown as answers.

unable to get Data.IterationIndex property inside class method.

1 Answer 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Priyanka
Top achievements
Rank 1
Priyanka asked on 26 Aug 2013, 09:45 AM
Hi Telerik team,

I want to use one method in multiple tests of same project so for that i have create the class in namespace and create the method inside that class.
using the below link referance:-
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/utility-in-standalone.aspx

In that method, i have to write the data in excel sheet based on some condition.
For writing data to the current row i am using excelApp.Cells[Data.IterationIndex + 2 , 1] = "Pass: Record save"; 
But  i am getting following error: 
c:\Users\priyanka.kadam\Documents\Test Studio Projects\Test_Validations\Function_CheckAlert.tstest.cs: Line 48: (CS0103) The name 'Data' does not exist in the current context
c:\Users\priyanka.kadam\Documents\Test Studio Projects\Test_Validations\Function_CheckAlert.tstest.cs: Line 54: (CS0103) The name 'Data' does not exist in the current context

Please help me to resolve this problem at earliest as possible.

Thanks,

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 27 Aug 2013, 08:22 PM
Hello Priyanka,

"Data" is an object that is defined in the base class "BaseWebAiiTest", which is the base class for all Test Studio test code behind files. Since your utility class does not derive from this base class, you are not inheriting its definition. But please do NOT use BaseWebAiiTest for your utility class because the base class will not get initialized properly, including the Data object.

Instead you can do one of two things:

  • Pass "Data" as a parameter to your utility class methods
  • Pass "Data" as a parameter to the constructor of your utility class, store it in a variable and refer to the variable in your utility class methods

Regards,
Cody
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Priyanka
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or