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

Data Driven not functioning as expected

3 Answers 125 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ching ping
Top achievements
Rank 1
ching ping asked on 01 Dec 2010, 09:40 AM
Hi Telerik team,

I tried to create a test with data binding from excel file but it's not functioning as i expected. Lets say i have a test with below steps:

1. navigate to www.google.com
2. type 'Telerik' in the search text box, and later, bind the data from my excel file to this step
3. click on the 'Search' button
4. verify the search results
5.navigate to www.yahoo.com

My idea here is to execute step 1, then repeat step 2, 3, 4 with the data binded. Lastly, execute step 5. But the result i get when i run the test is executing step 1, then repeat step 2,3,4,5 for the data binded.

Any advice on this?

3 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 01 Dec 2010, 06:25 PM
Hi Ching,
        when you use data-binding in a test all the steps in a test are repeated for each iteration.
You state that:
"But the result i get when i run the test is executing step 1, then repeat step 2,3,4,5 for the data binded."

But actually what happens is all the steps 1,2,3,4,5 are repeated: not just 2,3,4,5.

Let me explain how it works with an example similar to yours:
You have a test consisting of the following steps:
1) Navigate to Yahoo.com
2) Navigate to Google.com
3) Enter $(search item) in Google search box (This step uses data-binding to an Excel file);
4) Verify element contains String "results" (as in "About 8,580,000 results");
5) Navigate back

And let's say this test is bound to an Excel file. The first column of your Excel file looks like this:

search item

Telerik

WebUI

Testing 

Interface


This is the column that holds the values which you would like to pass to Step 3. If you've configured the data-binding correctly, the test is going to go into a loop and execute 4 times for each of the given values. Here's exactly what will happen:
Iteration 1)  1. Navigate to Yahoo.com
                      2. Navigate to Google.com
                      3. Enter Telerik in Google search box
                      4. Verify element contains String "results"
                      5. Navigate back
Iteration 2)  1. Navigate to Yahoo.com
                      2. Navigate to Google.com
                      3. Enter WebUI in Google search box
                      4. Verify element contains String "results"
                      5. Navigate back
Iteration 3) 1. Navigate to Yahoo.com
                      2. Navigate to Google.com
                      3. Enter Testing in Google search box
                      4. Verify element contains String "results"
                      5. Navigate back
Iteration 4)  1. Navigate to Yahoo.com
                      2. Navigate to Google.com
                      3. Enter Interface in Google search box
                      4. Verify element contains String "results"
                      5. Navigate back

If the test passed successfully for all iterations you will get a message:
 Pass - 20 passed out of total 20 executed.
It's 20 because the test consists of 5 steps. 5 steps * 4 iterations = 20.
The log will contain separate information about the execution of each iteration.

Obviously sometimes you don't want to execute the whole test multiple times. Instead you want just a small section to execute multiple times (just like a Loop statement inside your test). In this case you can use the "Add Test As Step" feature (see screenshot 1). You create a separate test which contains all the steps that need to "Loop" in accordance with your Excel file. This is the test which will have Data Binding.  
Then you create your "main" test without any sort of Data Binding. You add the "Loop" (i.e. Data Binding) test as a test step. Now, when you execute the Main test  - it will execute once : only your "Loop" subtest will execute multiple times.

I hope you'll find my answer helpful! Please don't hesitate to contact us again if you have any further questions!

Kind regards,
Stoich
the Telerik team
Interested in Agile Testing?

Tune in Wednesday, December 1st for a very special Webinar focused on Agile Testing. Click here to register for free!
0
Phil
Top achievements
Rank 1
answered on 29 Apr 2011, 12:00 AM
I have a slightly different data driven test issue.  My test project (Dev edition) contain 3 tests as depicted below:

Test A: Log into the website (data bound to excel sheet containing 2 customer logins)
Test B: Navigate to a particular page
Test C: Perform validation on that page

-and-

Test C begins with Test A and Test B as "test as steps"

The problem is that when Test A runs as a step it iterates the Excel data independently before continuing on to Test B and Test C.  I need Test A,B,C to share the same data and iterate together.  Otherwise the 'test as step' is not providing much modularity.  And modularity is a requirement for the kind of validation I need to do.  How do I resolve this issue?

Thanks,

Phil
0
Stoich
Telerik team
answered on 04 May 2011, 12:16 PM
Hi Ching,
  here's what you can do:
Don't bind Test A separately. Instead bind Test C (i.e. the "containing" test) to the database that Test A needs to use. Now set Test A to inherit its parent data source (screenshot 1). Now when you run Test C  (main test) it will run they way you need it to.

Hope to hear from you soon.

Best wishes,
Stoich
the Telerik team
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
Tags
General Discussions
Asked by
ching ping
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Phil
Top achievements
Rank 1
Share this question
or