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

Extracting a value or text from a RadDropDownList

5 Answers 316 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Efficio
Top achievements
Rank 1
Efficio asked on 05 Feb 2020, 08:47 PM

Is it possible to extract a value or text from a RadDropDownList?  In my test when I use element highlighting I see the a RadDropDownList and a span option.

The RadDropDownList has an extraction for things like item count and visibility but not text or value (which to me would be the most common).  The span has an option to extract value, but the only real reason to use the span is because it is part of the drop down list control as it is rendered (Classic mode).  One problem with the span is that this creates another element on top of the drop down list element which makes tests harder to maintain and understand, and it isn't associated with the drop down list in any way.  The major problem, however, is that the recorder creates find logic with no relation to drop down list and even uses the text content to identify the span.  This makes the test fragile and prevents us from reusing an extraction step for tests that use different values in the drop down list.

Am I missing something here?  If this just isn't going to work like I think it should is there a better way to accomplish this?  Would it be possible to create find logic to locate a span element based on a parent with a specific ID (the ID of the drop down list)?

 

 

5 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 06 Feb 2020, 01:56 PM

Hello,

It is possible to use the built in feature to extract the value of a RadDropDownListItem in Test Studio. To do that, you need to expand the RadDropDownList and highlight the specific item there. You should see the available quick steps to extract that value (see radDropDownListItem.png).

The above suggestion will create the extract step and add new element to the Elements Explorer in your project. You can explore what filters are used to identify it. I did some tests against this public page and found that the default filters are based on TextContent of that item. You can adjust those settings under the Settings -> Find Logic. My further inspection of the DOM tree shows that there are no other attributes to identify the element in a unique way and that TextContent is the most reliable in this case.

Another option is to use a coded step to get all items from that RadDropDownList. You probably need to use chained filters to specify the parent RadDropDownList, to get all items under it. Then, you can have a custom logic to go through all of them and find the necessary value.

var items = Find.AllByExpression("id=~RadDropDownProducts_DropDown", "|", "tagname=li");

The above sample of chained filters can be used to create logic to located any element, that is under a specific parent element. Please check here for more details on how to create such filters in the user interface of Test Studio.

I hope the above information will be helpful to you. Please do not hesitate to contact us again, if you need further assistance or anything remain unclear.

Regards,
Plamen Mitrev
Progress Telerik

 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Efficio
Top achievements
Rank 1
answered on 06 Feb 2020, 04:02 PM

Shouldn't this functionality be part of the control itself (or result in a feature request to add it)?  It seems like the suggested technique has the same limitations of the span in the way the element is targeted.

We have a lot of drop down lists, and one of our testing techniques is to extract all values on a form before saving, save the form, and then go to the form in edit mode and verify the form values against the previously extracted values.  I feel like I'm asking for what would be a common use case so it is hard to justify writing custom find logic or coded steps for it.  I'm also trying to make our tests easy to create so that I can train others to do this, and I'd like them to be able to rely on the recorder as much as possible.

As far as the find logic goes, I had already created the following which seems to work (based on very limited testing).  I edited the element itself which means a coded step wasn't required.  It finds the element based on the ID and then the span inside which has the display text of the drop down list.  It seems to extract the TextContent of the inner most element which is good.

tagname=div,id=?ddlCategory,|,tagname=span,class=~rddlFakeInput

I'll continue with this approach, but I was hoping there would be an easier way.  Tight integration with Telerik controls was one of the major selling points of Test Studio for us.

0
Plamen Mitrev
Telerik team
answered on 07 Feb 2020, 01:20 PM

Hello,

The find expression that you shared is targeting the span element with specific class, using chained filters. That element shows the text content of the selected item from the RadDropDownList or the default value, if nothing is selected. Please let me know if that is what you need and I will create a feature request on your behalf for a quicker and easier option to get that value during recording.

If the above is not what you needed to automate, please share more details and a sample test against a publicly accessible page to help me understand it better. You can also go ahead and create and describe the requested feature yourself directly from the Request Feature button.

I hope that we can help you make it easier for you and your team to automate the application under test. Our goal is to cover most commonly used scenarios and there are always new ones that we aim to include to the recording and configuration.

I am looking forward to hearing from you.

Regards,
Plamen Mitrev
Progress Telerik

 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Efficio
Top achievements
Rank 1
answered on 07 Feb 2020, 02:46 PM

The expression I have seems to work and is based on my examination of the markup.  Telerik knows their controls better than I do and could create a more reliable built in way to do this from the recorder.  I find it hard to believe that no one else is using the controls in this way so I'm trying to make sure I'm not asking about something that doesn't make sense.  If I have a dynamic list of items in a drop down list, I want to select any random item, and then I later want to verify that that item was selected by comparing the extracted selected text value against the current selected text value.

The RadDropDownList has built in actions such as "Extract - RadDropDownList: all item count is '19'".  This is an example of an action that has knowledge of a Telerik specfic control that goes beyond just targeting an element (it knows there are 19 list items).  I'm suggesting it would be helpful to have an action for things like "Extract - RadDropDownList: selected value" or ""Extract - RadDropDownList: selected text" as those are the type of things that people typically need to extract and compare (more so than item count).

I can just create a feature request is this seems feasible.

0
Plamen Mitrev
Telerik team
answered on 10 Feb 2020, 09:41 AM

Hello,

Thank you for explaining the use case in more details. I created new public feature request on your behalf and our engineering team will analyze it further. I noted that it should apply for other similar controls, but you can add you own comment and additional clarifications as a comment in the feature request. You can also vote and follow it to get notifications for its progress.

We try to provide the most common steps that will be widely used by all users and we love to hear your feedback. That is how we can improve and adjust those quick steps.

Thank you for your feedback and for sharing the workaround that you are currently using.

Regards,
Plamen Mitrev
Progress Telerik

 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Efficio
Top achievements
Rank 1
Answers by
Plamen Mitrev
Telerik team
Efficio
Top achievements
Rank 1
Share this question
or