Can an element's find expression reference more than one column from the bound data source?
I manually added an element and am changing its find expression to reference values from data. However, after setting one filter to reference data, the next filter does not allow selecting a data column. Is this intentional?
Thanks,
Matt
7 Answers, 1 is accepted
By design Test Studio allows you to reference only one column from the bound data source option in the element find expression. The reason is that Test Studio records the find expression for any element as whole string which cannot be data bound twice.
From the provided screenshot I can see you are using Chained Find Expression which is specific enough and you should have no troubles locating your element. For this I would like to ask you why you need to reference more than one column from the bound data source? Do you have any issues locating specific element? If yes, please, describe in detail what exactly is the issue you have so I could assist you further.
Regards,
Vera
Progress Telerik
Hi Vera,
Thank you for your reply. Unfortunately, a Chained Find Expression alone is not enough to locate the desired element.
The feature under test is as follows: A user fills out a form, submits the form, and two rows are created in a transaction log. The transaction logs are rows in a table on the page and display information from the submitted form. The test goes through the workflow of filling out the form, submitting the form, and validating that the expected transaction logs appear. Part of validating the transaction log is to verify that a table row exists with the data values entered into the form. I hoped to build a find expression looking for a table row with inner text containing several values from data, because finding such an element verifies that the correct transaction log was created. Using only one data column in the find expression does not guarantee finding the correct element, because only the combination of the data values guarantees a unique row.
Would you mind elaborating on why Test Studio only allows referencing one data column in a find expression? I'm somewhat confused as to what you mean by the find expression being a "whole string". At what point in building the find expression is the reference to the data column populated with the actual data? What prevents the code from populating multiple values when building the find expression string?
Thank you,
Matt
Thank you for clarifying in detail what your scenario is. I got better understanding of what you want to achieve in your test.
For this I can say the desired functionality can only be accomplished with a coded solution using data driven testing. However, it is important to know that this is a very risky scenario for at least a couple of reasons:
- First reason is that data driven testing iterates per row. Which means that if you have 2 columns (for example one with `ID` and one with `Class`) it will iterate through both. The tricky part here is that for each iteration the `ID1` and `Class1` cannot be changed dynamically. You will be able to use only `ID1` and `Class1` as shown in the attached screenshot. If you want to use `ID1` and `Class3` it will not be possible unless you add another table row with those values.
- From the above said it comes the second reason which would be that you have to be able to cover all possible combinations so your scenario to be applicable.
Additionally, you can also check out how to use HTML Table Searching and Paging, as this article shows how to iterate in tables and look for specific content.
I believe this answers your questions, but please do let me know if there is anything not clear enough. I will be happy to assist you further.
Regards,
Vera
Progress Telerik
Hi Vera,
Thank you for your reply. Unfortunately, I do still have questions.
Regarding your concerns about 'ID1' and 'Class1', I am fine with only using data from one row at a time. To follow the ID and Class example, I am fine with always pairing 'ID1' with 'Class1', and 'ID2' with 'Class2', etc. I do not want to pair 'ID1' with 'Class3'.
Thank you for the link about table searching and paging. However, my issue is not specifically related to tables. What I seek is the following: Given a row of data with multiple columns, I want to create a find expression that references more than one column. I believe referencing multiple data columns in a find expression can be done through a coded step by concatenating string values from multiple data columns, but is this possible to do in a way that puts the desired element in the element repository to be referenced again by future tests?
Thank you!
I would like to apologize for any misunderstanding that might have appeared in our discussion and thank you for being patient and explaining what exactly your use case is.
From the shared details on your end I can say the scenario is much clearer to me now. Given this, the direct answer to your questions is yes, you can reference multiple data columns in a find expression using both Coded Step and Standalone Code File.
To assist you further with this, I have created a sample test scenario for with detailed comments in it, explaining how the above mentioned can be achieved. In few words, what I did is to create a standalone code file in your project which consists of two methods – one that defines the find expression and another that finds the element. Once you create this code file you will be able to use it in any other test in your project. In addition to this I have created a coded step in the test itself which calls the first predefined method from the Code Item and uses the element with the actual data from `Local data` tab (it is located in the WebTest).
Please, refer to the attached project and keep in mind that this test cannot be executed and it is only an example on how to achieve the desired functionality. You should modify it accordingly to work properly for your project.
Let me know if you have further questions.
Regards,
Vera
Progress Telerik
Hi Vera,
Thank you for the sample test scenario. I see now how to use a coded step to reference multiple data columns in a find expression. I came across https://docs.telerik.com/teststudio/testing-framework/write-tests-in-code/intermediate-topics-wtc/element-identification-wtc/find-expressions which also helps to explain using an HtmlFindExpression in a coded step.
Just to clarify, using a coded step is currently the only way to accomplish a find expression referencing multiple data columns? Is there a plan to introduce this feature in the built in Find Element tool?
Thank you!
I am happy to hear you find the provided resources useful.
To answer your question, yes, at this point the functionality for referencing multiple data columns in find expression for element can only be achieved using coded step. However, I have submitted a Feature Request in our feedback portal and I suggest you to vote for it since it will increase the chance to be prioritized and implemented. You can follow its progress from that link as well.
Let me know if I can assist you any further.
Regards,
Vera
Progress Telerik