From: Ezra Zygmuntowicz Date: 2006-05-26T08:06:09+09:00 Subject: Re: Multiple Arrays On May 25, 2006, at 1:41 PM, eric tabora wrote: > eric tabora wrote: >> Justin Collins wrote: >>> Justin Collins wrote: >>>> Hi Eric, >>>> more descriptive names, too. >>>>> $ie.textField(:name, "height").set("#{size_array2}") >>>> "height").set("#{size_array2[index]}") >>>> >>>> >>>> -Justin >>>> >>> >>> Oops - height_array2 => height_array. >>> >>> -Justin >> >> I think that I'm going to try the route of using one array instead of >> two. My new array looks something like: >> >> size_array = [ 6x9, 5x7, 8.5x11 ] >> >> Is there some way that I can tokenize the array values to populate my >> text fields: >> >> $ie.textField(:name, "width").set("#{size_array}") >> >> $ie.textField(:name, "height").set("#{size_array2}") > > > I answered my own question. How does this look? > > def size_entry > > size_array = IO.readlines("OneOffSizes.txt") > size_array.each_with_index do |size, index| > > size = size.split('x') > > $ie.textField(:name, > "SearchCreativeMaterialsPortletInstance > {actionForm.desiredSizeHorizontal}").set("#{size[0]}") > > $ie.textField(:name, > "SearchCreativeMaterialsPortletInstance > {actionForm.desiredSizeVertical}").set("#{size[1]}") > > $ie.button(:value, "Search").click > sleep(1) > > #assert_size > end > > end #size_entry > > -- > Posted via http://www.ruby-forum.com/. > You can also use Array#zip to iterate over two arrays at once: irb(main):012:0> a = ['one', 'two', 'three'] => ["one", "two", "three"] irb(main):013:0> b = [1,2,3] => [1, 2, 3] irb(main):014:0> a.zip(b).each do |pair| irb(main):015:1* puts pair[0] irb(main):016:1> puts pair[1] irb(main):017:1> end one 1 two 2 three 3 => [["one", 1], ["two", 2], ["three", 3]] irb(main):018:0> -Ezra