To select random number from select list

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.

Hi,

Pranjal J. 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 H.

To get a random element from an array

some_array[rand(some_array.size)]

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

On Apr 10, 2:37 am, Julian L. [email protected] wrote:

=
in random.
How can i do it ?

Please help.
Thanks in advance.

Posted viahttp://www.ruby-forum.com/.- Hide quoted text -

  • Show quoted text -

wow you love thouse videos

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs