RUBY/WATIR/RASTA: Pass the value from the excel/rasta to an array in Ruby?

女生的网名这么多〃 提交于 2019-12-02 14:03:47

There is a favored library called roo. In the linked page, it will tell you how to install the library, then use it to get values out of excel.

require 'rubygems'
require 'roo'

HOURLY_RATE = 123.45

oo = Openoffice.new("simple_spreadsheet.ods")
oo.default_sheet = oo.sheets.first
oo.first_row.upto(oo.last_row) do |line|
  @browser.check(:value => oo.cell(line,'A'))
  @browser.button(:name => 'save').click
end

i can get the values in the excel but i don't know how will I drop them as array in Ruby

My code looks like this.. but it doesn't work

......
if array 

 arrayLabel = [:array]

    arrayLabel.each do |i|
    @browser.checkbox(:text => i).click 
    @browser.button(:name => 'save').set
            end


end 
..............

:array , is the column name where i get the value to be pass in ruby

And also How to do if when the data in the array is not found on the list of checkbos choices?

Find some online tutorials for Ruby, or purchase and work your way through a book like Everyday Scripting With Ruby.

Everyone has to start someplace, but at the moment, it seems you understand so little, and are over-reaching your abilities to the extent that the people who are trying to help you can barely make sense out of your question or what you are trying to do.

Next, work in baby steps, so you can tell what is working and what is failing, and gradually work your way up to what you want to do.

For example, in your case, get the Roo gem installed, and figure out how to use it to read from your spreadsheet and just print stuff on the screen.

Once you can do that, Then try to read the infomation into an array, and print the array out to the screen (so you know stuff got where you need it to go)

Now, write come code using Watir that has values hardcoded to click things etc and fill out the form you are working on etc.

Once you know that is working, combine that with your code to read the spreadsheet into an array, and replace the hard-coded values with stuff pulled from the array that you made from the spreadsheet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!