DataBind T-SQL with parameters

6 posts, 1 answers
  1. Yohai
    Yohai avatar
    4 posts
    Member since:
    Apr 2012

    Posted 07 May 2012 Link to this post

    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 



  2. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 08 May 2012 Link to this post

    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
  3. Yohai
    Yohai avatar
    4 posts
    Member since:
    Apr 2012

    Posted 09 May 2012 Link to this post

    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



  4. Answer
    Cody
    Admin
    Cody avatar
    3354 posts

    Posted 09 May 2012 Link to this post

    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
  5. Yohai
    Yohai avatar
    4 posts
    Member since:
    Apr 2012

    Posted 14 May 2012 Link to this post

    Thanks, its works as you said.
  6. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 14 May 2012 Link to this post

    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
Back to Top