SelectBox - Index Reset?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
volcamp55
Posts: 2
Joined: Fri Aug 07, 2015 4:36 pm

SelectBox - Index Reset?

Post by volcamp55 » Tue Oct 20, 2015 4:30 pm

I have a "selectbox" object which contains several selections .. for simplicity, we can assume the listed entries contain the values "1", "2", "3", "4", and "5". I use the following C# code to find a particular entry and move to it to "select" the item:

ListItem item = "/container[@caption='selectbox']/listitem[@text='4']";
item.MoveTo();
item.Click();

Now, if I use this same code to find the "3" entry, it isn't found in the selectbox. Is this because I already moved to the index for the "4" entry, so that the next search starts at the "4" entry (which is past the "3" entry)? If so, how should I go about resetting the selectbox index to the first element?

Thanks ... Rick

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

Re: SelectBox - Index Reset?

Post by Support Team » Thu Oct 22, 2015 1:26 pm

Hello volcamp55,

Depending on the technology you are using you can try the following line on the select box element.
repo.Selectbox.Self.Element.SetAttributeValue("SelectedItemIndex", "0")
If my suggestions doesn't work we need more information in order to analyze the issue.
Please send a Ranorex Snapshot file from your application.

Regards,
Bernhard
.
Image

volcamp55
Posts: 2
Joined: Fri Aug 07, 2015 4:36 pm

Re: SelectBox - Index Reset?

Post by volcamp55 » Thu Oct 22, 2015 3:55 pm

Thanks for the suggestion, Bernhard. I will try that out when I can gain access to a system that I can test this out on. Basically, I have a web interface to control our system diagnostics. The drop-down lists are contained in "selectbox" web controls. If your suggestion doesn't work, I will send you snapshots of the files.

Thank you again for your help ... Rick