optimal way to select nth item in listbox or combo box using selenium webdriver

38 views
Skip to first unread message

sam6

unread,
Feb 2, 2015, 5:01:26 AM2/2/15
to seleniu...@googlegroups.com
Hi ,

I have a list box having large number of items say 100 and I want to select 91st item in the list , what is the best or optimal approach of travesing to and selecting that item using webdriver.

Please suggest
Thanks
Sam

david...@sap.com

unread,
Feb 2, 2015, 9:18:31 AM2/2/15
to seleniu...@googlegroups.com
If the underlying structure of the list isn't too complex you could do something like:
ReadOnlyCollection<IWebElement> listElements = listBoxElement.FindElements(By.TagName("li"));

and ...

IWebElement item = listElements[91]; // Some trial by error may be necessary depending on whether it starts at 0 or 1. Some implementations have an empty item at [0].
Reply all
Reply to author
Forward
0 new messages