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

Data Driven testing & descriptive programming

4 Answers 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Naga
Top achievements
Rank 1
Naga asked on 09 Apr 2012, 08:58 AM
Hello!!!
 I am trying to do feasibility analysis using Test studio.Can anyone let me know how can we achieve parameterization or data driven from an external file.
2.Can we perform descriptive programming using test studio. for example i have dynamic objects that are populated on the application then
 can i write a driver and store all these elements in a seperate file such as excel and then basing on the requirement can i pass this elemnet as an arguement and perform the operation. If Yes please provide the process as my application has lots of dynamic objects.

3.How can i write my own code instead of recording.
4.Where can i find all the methods with which i can write my own code.(An exampke with code would be helpful)
5.How  can i create reusable functions and call them in my script.All these are application specific reusables such as login.
6.How can pass the test data to my variables within a script.


I am very much in need of all these .Your help in this regard would be highly appreciated.

4 Answers, 1 is accepted

Sort by
0
N1t1nA
Top achievements
Rank 1
answered on 11 Apr 2012, 12:14 PM
Hello Naga 

Regarding your Points, Please find my comments

1. how can we achieve parameterization or data driven from an external file. 

NA
Here is the article from which you can see,  

http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/data-driven-testing.aspx 

You can also download the samples from here 
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/access-sql-database.aspx 

2. Can we perform descriptive programming using test studio. for example i have dynamic objects that are populated on the application then
 can i write a driver and store all these elements in a seperate file such as excel and then basing on the requirement can i pass this elemnet as an arguement and perform the operation. If Yes please provide the process as my application has lots of dynamic objects 

NA
When you add Elements into your Project using Test Studio built in Feature, Add Elements to Project, Test Studio automatically capture the Properties of an Element and Stored in readonly file Pages.g.cs or Pages.g.vb, depends upon the which language you are using for Project(C# or VB), for dynamic elements you can use Advanced Find Logic as mentioned in this article
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/elements-pane-overview/find-element.aspx 

3.How can i write my own code instead of recording. 

NA
This is simple, just create a New Test (NewTest1.tstest) and Add Code behind file and start Coding
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/coded_steps.aspx 

4.Where can i find all the methods with which i can write my own code.(An exampke with code would be helpful) 

NA
Same as 3

5.How  can i create reusable functions and call them in my script.All these are application specific reusables such as login. 

NA
you can use Modularity Driven approach, Create Common Methods for Lo-gin, Log-out and use them in Test wherever its required
Here is the Example

//Log-in Method

public void LoginToSilverlightClient(string username, string password)

{

    //Maximize the Browser

    Activebrowser.Window.Maximize();

    //Launch the URL

    Activebrowser.NavigateTo("application url");

    //Wait for UserName Textbox Exists in DOM

    Pages.app.Username.Wait.ForExists(timeout);

    //Enter UserName

    Pages.app.Username.Text = username;

    //Wait for Password Textbox Exists in DOM

    Pages.app.Password.Wait.ForExists(timeout);

    //Enter Password

    Pages.app.Username.Text = password;

    //Wait for Login Button Exists in DOM

    Pages.app.SubmitButton.Wait.ForExists(timeout);

    //Click on Login Button

    Pages.app.SubmitButton.Click(false);

}


Access this in Coded Step 
 [CodedStep("Login intoApplication")]
        public void LoginintoYahoo()
        {
            //Create object for Login class
            Login objlogin = new Login();

            //Call the Method to Login into Application
            objlogin.LoginToSilverlightClient("test", "123456");
        }

6.How can pass the test data to my variables within a script. 

NA
Same as 5

Please let me know if any other info required 

--Nitin--
twitter:@N1t1nA
http://www.linkedin.com/groups/Telerik-Test-Studio-4281132
0
Anthony
Telerik team
answered on 11 Apr 2012, 06:11 PM
@Naga
Nitin's suggestions are accurate. I'll add to a few of his points, however:

2. You can find the Add To Project Elements feature on the Elements Menu. Once your elements are in the Elements Explorer, you can easily Reference them in Code.

4. We have a full Online API Reference, Getting Started with the Testing Framework, and several Code Sample articles.

5. This is most easily achieved with the Test as Step feature.

@Nitin
Thank you for assisting another customer. I awarded you Telerik points for your effort.

 

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Mousumi
Top achievements
Rank 1
answered on 28 Oct 2014, 05:52 AM
hello Anthony,

How we ll navigate to yahoo url by calling Login method as we have to pass the url in Login method only. i.e 
Activebrowser.NavigateTo("application url");


Thanks,
Mousumi
0
Boyan Boev
Telerik team
answered on 30 Oct 2014, 02:21 PM
Hi Mousumi,

We have already discussed this in your private ticket.

If you want to execute a coded step in *.tstest your code should look like:

[CodedStep(@"New Coded Step")]
        public void OpenUrl()
        {
            ActiveBrowser.NavigateTo("http://www.yahoo.com", true);
        }

If you want to do it in unit test:

[TestMethod()]
        public void WebTest1()
        {
            // Launch an instance of the browser
            Manager.LaunchNewBrowser();
  
  
            // Navigate to : 'http://www.yahoo.com/'
            ActiveBrowser.NavigateTo("http://www.yahoo.com/", true);
  
  
  
        }


Hope this helps.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Naga
Top achievements
Rank 1
Answers by
N1t1nA
Top achievements
Rank 1
Anthony
Telerik team
Mousumi
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or