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.
5 Answers, 1 is accepted
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.
and send us your feedback!
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?
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.
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.
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.