From: Heesob Park Date: 2008-04-10T18:36:52+09:00 Subject: Re: to select random number from select list Hi, Pranjal Jain wrote: > HI > I am having a list. I want to select a number in random from that list? > which command I can use it for doing this? > > For example : > > $ie.row(:class =>"bgTableAltColors",:index > =>"4").cell(:class,"padTableRightBorder").select_list(:class,"Formelement").option(:text,"Test > Automation - Scripting").select > > here instead of "Test automation -scripting" I want to select a option > in random. > How can i do it ? > > Please help. > Thanks in advance. If a list is given: list = ["a","b","c"] You can do it like this: list.sort_by{rand}.first Regards, Park Heesob -- Posted via http://www.ruby-forum.com/.