How to get Selected item list from a combo box dropdown list

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
vivek.guvva
Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

How to get Selected item list from a combo box dropdown list

Post by vivek.guvva » Thu Apr 14, 2016 5:55 pm

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
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to get Selected item list from a combo box dropdown list

Post by odklizec » Fri Apr 15, 2016 9:32 am

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:

Code: Select all

/dom[@domain='mediaviewqc.nielsen.com']/body/div/div[#boundlist-1215-listWrap]/ul/li[@class~'-selected']
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:

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();
	}
Where repoItemInfoElement points to the above mentioned repo element.
Pavel Kudrys
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

joshmike
Posts: 2
Joined: Tue Apr 19, 2016 11:27 am

Re: How to get Selected item list from a combo box dropdown list

Post by joshmike » Tue Apr 19, 2016 11:33 am

hi vivek, put property "checked" in that element, it will automatically unselect when you select other option.