Hi Telerik Team,
I have a method that generates a random number that is used to populate a textbox. This code works fine within a test but I would like to move it into a separate library where all my tests within the project can access & use it (the broader goal being to put multiple methods in one place).
So right now I have WebTest1 which has a coded step to call this function (getNumber) however it is failing with this error:
c:\QA_Test_Automation\Test Suite\Work In Progress\WebTest1.tstest.cs: Line 82: (CS0120) An object reference is required for the non-static field, method, or property 'Test_Suite.Utility.getNumber()'
Here is how I am calling the method from within WebTest1.tstest:
And here is how I have the method setup within the UtilityTest1.tstest:
Both files exist within the same project. Any clue on what I am doing wrong? I was also following this link:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/utility-in-standalone.aspx
My version of Test Studio is 2012.2.1527.0
Thank you for any help.
I have a method that generates a random number that is used to populate a textbox. This code works fine within a test but I would like to move it into a separate library where all my tests within the project can access & use it (the broader goal being to put multiple methods in one place).
So right now I have WebTest1 which has a coded step to call this function (getNumber) however it is failing with this error:
c:\QA_Test_Automation\Test Suite\Work In Progress\WebTest1.tstest.cs: Line 82: (CS0120) An object reference is required for the non-static field, method, or property 'Test_Suite.Utility.getNumber()'
Here is how I am calling the method from within WebTest1.tstest:
[CodedStep(@
"Enter text '' in 'TxtSearchText'"
)]
public
void
WebTest1_CodedStep()
{
int
randomNum = Utility.getNumber();
Actions.SetText(Pages.COBRApointTPAPortalHome.TxtSearchText, randomNum.ToString());
}
And here is how I have the method setup within the UtilityTest1.tstest:
public
class
Utility {
public
void
getNumber(){
System.Random random =
new
System.Random();
int
randomNum = random.Next(100000000,999999999);
}
}
Both files exist within the same project. Any clue on what I am doing wrong? I was also following this link:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/utility-in-standalone.aspx
My version of Test Studio is 2012.2.1527.0
Thank you for any help.