This is a migrated thread and some comments may be shown as answers.
Passing values between datasets?
8 Answers 77 Views
This is a migrated thread and some comments may be shown as answers.
Cheryl
Top achievements
Rank 1
Cheryl asked on 28 Mar 2012, 02:50 AM
Hello

Is it possible to set up a databind using T-SQL where a filtering value will be from another dataset?

Eg
datasetA = login info
datasetB = product info

So, once logged in for each interation in datasetA, I need to be able to pass an ID value from datasetA to datasetB which is attached to a Test as Step.

I ultimately will need to loop through the tests for multiple logins and in turn for multiple products


Thanks for your help
Cheryl

8 Answers, 1 is accepted

Sort by
0
Cheryl
Top achievements
Rank 1
answered on 28 Mar 2012, 04:21 AM
Apologies, this was supposed to be in the Stand Alone version, not the plug in
0
Ohsha
Top achievements
Rank 1
answered on 28 Mar 2012, 04:18 PM
Hi Cheryl, 

What's the different of your scenario with the following?

Multi-Level Tests

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

Data bound Test A calls data bound Test B

Example
  • Test A has 3 steps: login, Test as Step (Test B), and logout.
  • Test B performs a data driven text input, search, and verification.

 

Note:  Both Test A and Test B are data bound, 


0
Anthony
Telerik team
answered on 29 Mar 2012, 03:17 PM
Hello Cheryl,

To clarify your scenario:
  • TestA calls TestB via Test as Step
  • TestA is bound to DatasetA
  • TestB is bound to DatasetB
  • TestB's InheritParentDataSource property set to False

And you'd like to reference columns from DatasetA in TestB? That won't work and you'll receive an error ("Column does not exist"). A test can only be bound to one data source.

I thought of a work-around, however. You can Pass a Variable between Parent and Child tests using the Extract feature. If you don't want to perform an Extraction on an element in the browser to set the variable to be passed, you can reference the value in a specific column of TestA's data source for the current iteration, set that as an Extracted Value in Code, and use that variable in TestB.

Here's an example of the coded step in TestA:

string current = Data["Col1"].ToString();
SetExtractedValue("parVar", current);

Now in TestB you can bind a step with $(parVar), and also continue to bind steps using columns from TestB's DatasetB.

Greetings,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Cheryl
Top achievements
Rank 1
answered on 02 Apr 2012, 12:27 AM
As per my initial question "Is it possible to set up a databind using T-SQL where a filtering value will be from another dataset?"

what I want to know if it is possible to set up datasetB BASED on a record value from datasetA

So datasetA has login, password, accesslevel.
I want datasetB to take into account the accesslevel of the datasetA for each iteration

and I was wanting to know if this could be somehow fed into the databind being attached to the test
0
Cheryl
Top achievements
Rank 1
answered on 02 Apr 2012, 12:31 AM
Hi Anthony

Not entirely correct, although your answer has provided me a solution regarding something else I needed to work out how to do, so thanks for that!

I want to know if there is a way to set up datasetB BASED on a record value from datasetA

So datasetA has login, password, accesslevel.

I want datasetB to take into account the accesslevel of the datasetA for each iteration - ie only get records for accesslevel=x where x matches each iteration through datasetA

and I was wanting to know if this could be somehow fed into the databind being attached to the test

Thanks for all your help
0
Anthony
Telerik team
answered on 02 Apr 2012, 04:41 PM
Hello Cheryl,

No, you cannot use a data bound variable from datasetA in the T-SQL statement for datasetB through the Test Studio UI.

As a work-around, however, you can probably implement a complex coded solution. We haven't tested this, but in theory it should work:
  • TestA has a coded step that writes the current iteration's value for the AccessLevel column to a file on disk.
  • TestB has custom code to read the value from the file, and use it to set the T-SQL statement.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Cheryl
Top achievements
Rank 1
answered on 03 Apr 2012, 12:23 AM
Hi Anthony,

Thanks for your answer.

I'm wondering if I could use extracted data from the main test (eg AccessLevel) and use it in a coded step that creates a dataset via a SQL call.  I can pick up on this AccessLevel value ok and then pass it to the SQL call and it writes to the log correctly so I am picking it up, but i'm not sure how (or if its possible) to then bind the new dataset to the "test as a step".

Can it be done, and if so how?

Thanks

Cheryl
0
Anthony
Telerik team
answered on 04 Apr 2012, 03:22 PM
Hello Cheryl,

Yes, this is possible, however the new dataset created will have to exist locally on disk (like an Excel file). That way TestB is already data bound to that dataset, and the coded step in TestA simply dynamically populates it.

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Asked by
Cheryl
Top achievements
Rank 1
Answers by
Cheryl
Top achievements
Rank 1
Ohsha
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or