how to select multiple items in a listbox

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

how to select multiple items in a listbox

Post by hobli » Mon May 31, 2010 10:42 am

Hi,

I want to select multiple option items in a listbox with the following html code:

Code: Select all

<select myattri='cool' name="listbox" id="SelectSimple" size="4"  multiple>
    <option value="1">item 1</option>
    <option value="2" >item 2</option>
    <option value="4" selected>item 4</option>
    <option value="0">All</option>
    <option value="3" selected>  item 3  sdfasfdasdf asdf asd fasfdasd asd </option>    
</select>
When I check the tagValue of the selectTag, it always return single option selected, is it supposed to return some multiple values like "4,3"?

And the "Selected" attribute of all optionTag is always True for IE, always False for FF, I am not sure if this is a bug.

Pls advise and provide a sample if possible.

thanks a lot

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to select multiple items in a listbox

Post by Support Team » Mon May 31, 2010 1:29 pm

Hi,
hobli wrote:When I check the tagValue of the selectTag, it always return single option selected, is it supposed to return some multiple values like "4,3"?
Sorry there is no method for SelectTag to choose multiple items. But you can use following method
//Use mehtod in main or another place
Ranorex.SelectTag selectTagSelectSimple = "YourPath";
selectMutlipleOptions1(selectTagSelectSimple.Options,1,2,3,4)

//Method
private static void selectMutlipleOptions(IList<Ranorex.OptionTag> iList, params int[] iValues)
{          	
	foreach(OptionTag opt in iList)
	{
		if (((ICollection<int>)iValues).Contains(Convert.ToInt32(opt.Value)))
		    opt.Selected = true;
	}	
}
hobli wrote:And the "Selected" attribute of all optionTag is always True for IE, always False for FF, I am not sure if this is a bug.
This is also solved with the bug you posted a few days before and will be released in next Ranorex service release.

Regards,
Peter
Ranorex Support Team
.
Image

hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

Re: how to select multiple items in a listbox

Post by hobli » Mon May 31, 2010 2:07 pm

thanks.

hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

Re: how to select multiple items in a listbox

Post by hobli » Tue Jul 06, 2010 4:39 am

Hi,

I testing this with Ranorex 2.3.2, change optionTag's 'selected' attribute only works with IE at this moment, but not with FF 3.6.6:

selected attribute values can be changed for FF, but no visual effect on the webpage, browser still indicate the original selection status of option item.

thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to select multiple items in a listbox

Post by Support Team » Tue Jul 06, 2010 1:44 pm

Hi,

Sorry but someone forgot to implement this valueless attribute for Firefox. :oops: In the upcoming version this bug is fixed. We expect the new version (2.3.3) to be available this week.

Regards,
Peter
Ranorex Support Team
.
Image

hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

Re: how to select multiple items in a listbox

Post by hobli » Wed Jul 07, 2010 4:13 pm

that's fast. thanks.