Page 1 of 1

SelectBox - Index Reset?

Posted: Tue Oct 20, 2015 4:30 pm
by volcamp55
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

Re: SelectBox - Index Reset?

Posted: Thu Oct 22, 2015 1:26 pm
by Support Team
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

Re: SelectBox - Index Reset?

Posted: Thu Oct 22, 2015 3:55 pm
by volcamp55
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