Something like this?
options = browser.select_list(:id, "foo").options
com_list = String.new
options.each do |option_text|
com_list << "#{option_text}, "
end
Hope it helps.
orde
On Oct 20, 10:28 am, Joe Fl <[email protected]> wrote:
> How can take those values from the list and put them in a string so I
> can use the split method?
>
> the values from the list box are
> ACG GI Circle
> Advisory Board CDK Sandbox
> Advisory Board Sandbox
> AFCC
> Akron Children's Hospital
> Bayer Pulmonary Hypertension Community
> Better Health Greater Cleveland
> Board of Governors
> Case Western Reserve University - School of Medicine Alumni
> CHB Demo
> Children's Hospital Boston
> Children's Hospital Boston Alumni Association Satellite Community
> Children's Hospital Boston PPOC Online Community
> Covance Virtual Advisory Board
> Future Forum
> Future Forum Editorial Board
> GI Consultant Forum
> Janssen Advisory Board Forum
> Medical Affairs Leaders Forum
> NAPH Member Community
>
> I want to place them in a string called com_list with a comma between
> each value.
>
> I currently retrieve them by above code but it would a lot easier to
> work with them in a string.
>
> Thank you,
> Joe
>
> On Oct 19, 3:17 pm, Chuck van der Linden <[email protected]> wrote:
>
>
>
>
>
>
>
> > On Oct 19, 11:14 am, Joe Fl <[email protected]> wrote:
>
> > > Hi,
>
> > > I have figure it out.
>
> > > Code...
> > > names = $browser.select_list(:name,'communities').options
>
> > > community_names_arr = Array.new
>
> > > commuName = ""
>
> > > name_number = 0
>
> > > names.each do |name|
>
> > > puts commuName = "#{name_number}: #{name.text}"
>
> > > name_number = name_number + 1
>
> > > end
>
> > > this gives me the text to each option in the listbox.
>
> > You might want to make use of .each_with_index to make your code a
> > little easier and cleaner
>
> > names = $browser.select_list(:name,'communities').options
>
> > community_names_arr = Array.new
>
> > commuName = ""
>
> > names.each_with_index do |name, i|
>
> > puts commuName = "#{i}: #{name.text}"
>
> > end
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]