Use a variable in element find logic

6 posts, 0 answers
  1. Bryan
    Bryan avatar
    19 posts
    Member since:
    Aug 2012

    Posted 01 Feb 2016 Link to this post

    I need to use the value from a variable to find an element to click.

    The variable value is being extracted from a database using C# (data binding won't work because I am already bound to the data, but this value did not exist at the time of binding).

    The variable name is varDocID

    I am trying to use it to compare to the OnClick event of the image I need to click in a grid with many instances of the same image.

    ~$(varDocID) does not work as it does not use the value and only tries to comapre to the variable name instead of the variable value.

    Please advise.

  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 04 Feb 2016 Link to this post

    Hi Bryan,

    Here is a detailed article about data driven find expression.

    If you create the variable in code you should then type its name manually in the drop down.

    Let me know if that works for you.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Joshua
    Joshua avatar
    2 posts
    Member since:
    Feb 2020

    Posted 13 Jan in reply to Boyan Boev Link to this post

    Hi,

    Sorry to resurrect this thread but I can't seem to find an answer anywhere else. I have a test that needs to do the same thing, and it does not have a data source binding, but I wish to use a variable (ExtractedValue) I have set in a coded step in the test.

    In the linked article, it reads "To be able to data drive an element, you need to add a data source and bind it to the test, which uses the element."

    But I don't have a data source, there is only the variable. I can't seem to get to the "coded data variable dropdown field" in the element find expression. Do I need add a dummy data source file that I won't use to enable the functionality, or is there an option I am missing?

  4. Elena
    Admin
    Elena avatar
    1256 posts

    Posted 13 Jan Link to this post

    Hi Joshua,

    I am sorry to hear you have encountered this misbehavior and will be glad to help you sort it out. 

    Actually, this is a known, for us in Test Studio, issue with the extracted variables in code and data driven elements' find expression - there is also a public item on the topic listed in our feedback portal. Although, the item dates back quite many years ago, the behavior is still the same. 

    The workaround to overcome this limitation is to set a dummy data source to enable the data driven logic for the test and allow the elements' find logic to be data driven. The easiest way to do this will be to add a local data source in the test. You need to enter data in a single cell of the data table and save the test. Then you will see the dropdown in the element's Edit mode

    Please, note that the extracted variables are not listed in this dropdown and you need to manually type the name in the input field, click on the curly brackets and then the Set button. 

    I hope that this will help you adjust the test you work on. Do not hesitate to get back to me in case of any further questions on the case. 

    Thank you for your understanding and cooperation in advance.

    Regards,
    Elena
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
  5. Joshua
    Joshua avatar
    2 posts
    Member since:
    Feb 2020

    Posted 14 Jan in reply to Elena Link to this post

    Hi Elena,

    Thanks for your reply and elaboration. I'll go ahead and add a local dummy data source as prescribed to enable the data-driven find expression functionality.

  6. Elena
    Admin
    Elena avatar
    1256 posts

    Posted 15 Jan Link to this post

    Hello Joshua, 

    Thanks for your understanding once again. Do not hesitate to get back to me in case you face any further difficulties with the data driven find expression scenario. 

    Regards,
    Elena
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Back to Top