Hi,
I have a dropdown list when we can select multiple items. I need to unselect the already selected items and then select the items as need per my testcase. Could you please let me know how to unselect the already selected items. I have attached a snapshot of the dropdown list for reference.
Thanks
Vivek
How to get Selected item list from a combo box dropdown list
-
- Posts: 31
- Joined: Mon Feb 22, 2016 7:21 pm
How to get Selected item list from a combo box dropdown list
You do not have the required permissions to view the files attached to this post.
Re: How to get Selected item list from a combo box dropdown list
Hi,
I can only guess that the combo stays open until you close it and that you can select/deselect items by simple click on item (i.e. without the need to press and hold Ctrl or Shift)? In this case, you can use below method to find all "selected" items and click each of them them to deselect them.
To get the list of all selected items, you need to use xpath like this: This xpath will return all selected items in your combo.
Now create a new repo element with such xpath. Then drag&drop it to recording module of your choice and from the appeared menu select UserCode >> New method with argument RepoItemInfo.
Then use this code, in newly created method, to create a list of selected elements and click each selected item to deselect it:Where repoItemInfoElement points to the above mentioned repo element.
I can only guess that the combo stays open until you close it and that you can select/deselect items by simple click on item (i.e. without the need to press and hold Ctrl or Shift)? In this case, you can use below method to find all "selected" items and click each of them them to deselect them.
To get the list of all selected items, you need to use xpath like this:
Code: Select all
/dom[@domain='mediaviewqc.nielsen.com']/body/div/div[#boundlist-1215-listWrap]/ul/li[@class~'-selected']
Now create a new repo element with such xpath. Then drag&drop it to recording module of your choice and from the appeared menu select UserCode >> New method with argument RepoItemInfo.
Then use this code, in newly created method, to create a list of selected elements and click each selected item to deselect it:
Code: Select all
//create a list of LiTags using the "Info" object passed to method as repoiteminfo parameter
IList<Ranorex.LiTag> liList =
repoItemInfoElement.CreateAdapters<Ranorex.LiTag>();
//click each found 'selected' combo item to deselect it
foreach (Ranorex.LiTag liItem in liList)
{
liItem.Click();
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: How to get Selected item list from a combo box dropdown list
hi vivek, put property "checked" in that element, it will automatically unselect when you select other option.