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

DataBind T-SQL with parameters

5 Answers 104 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yohai
Top achievements
Rank 1
Yohai asked on 07 May 2012, 06:14 AM
Hi,

How can we send from local database (for testing data) a value to our bind t-sql param?

sample:

If this is my local db: (column name is TempMachineName)
Machine1
Machine2

select Id from [ActiveMachines] where Name = '$(TempMachineName)'

and then to use the scalar value for some locator on DOM element

Thanks,
Yohai 



5 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 08 May 2012, 11:45 PM
Hello Yohai,

Your use case is not 100% crystal clear to me, but I must tell you there are a couple of limitations in Test Studio you may be running into:

1) Test Studio does not have a built-in feature to pass in parameters to any data binding definition, including T-SQL. What you can do however is to create your own Test Extension DLL where you have total control over the data source. You will need to implement the OnInitializeDataSource method. Whatever this method returns (other than null) will override any data binding that the test has.

2) Test Studio does not have built-in Data Driven find expressions. This can be done with a little bit of code however. http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/data-driven-find-expressions.aspx 


All the best,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Yohai
Top achievements
Rank 1
answered on 09 May 2012, 01:33 PM
Hi Cody,

I will try to make things more clear.
I have elements on the DOM that the id attribute is generated by guid from the database.

1. I create a new item from my UI.
2. I want to get the generated id from the database.
3. Store it in local parameter.
4. Use it  as a parameter to T-SQL and element selector 
 .

From your response i understand that i can't do it from your UI, only from code. am i right?

Thanks,
Yohai



0
Accepted
Cody
Telerik team
answered on 09 May 2012, 11:00 PM
Hi Yohai,

Correct, code is the only way to accomplish your goals. Going through your numbered list here's what I think it would take:

1) I am pretty sure this can be done using our standard record & playback i.e. our standard non-coded steps.
2) Using this code sample as a reference, pull the ID out of the database.
3) As part of step 2 above simply store it in a global variable in code.
4) Using this code sample as a reference, use the ID stored in the variable in code to find the UI element you're after.

I hope that gives you some idea how to implement a test that will achieve your goal.

All the best,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Yohai
Top achievements
Rank 1
answered on 14 May 2012, 11:26 AM
Thanks, its works as you said.
0
Cody
Telerik team
answered on 14 May 2012, 09:52 PM
Hello Yohai,

Glad to hear it! Thank you for the update.

Greetings,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Yohai
Top achievements
Rank 1
Answers by
Cody
Telerik team
Yohai
Top achievements
Rank 1
Share this question
or