> We are using watir in our project, and we want to do the
> Parameterization for few things in the script using excel sheet.

Before I run my tests, I input test data through the GUI, using a CSV. Here
is some code, but a pretty simple thing to do.

 def enter_employees()
  ObjectMap.new.instance_eval  do
    File.open('C:\auto_tests\test_data\employee_data.csv','r') {|f| #use
block so file is automatically closed

      f.each_line { |line|
        next if /^;/ =~ line #check for ';' at start of line
        i = 0
        line.chomp.split(',').each{|x|
        i += 1
        next if x.nil? or x == "null" #skip nil or "null" values
        case i
        when 1 #country
          employee_country_id.select(x)
        when 2 #depot
          employee_depot_id.select(x)
        when 3 #first_name
          employee_first_name.set(x)
        when 4 #last_name
          employee_last_name.set(x)
        when 5 #user_id
          employee_user_id.set(x)
        when 6 #stream_id
          employee_stream_id.select(x)
        when 7 #time percentage
          employee_role.set(x)
        when 8 #tel
          employee_telephone.set(x)
        when 9 #e-mail
          employee_email.set(x)
        when 10
          start_date.set(x)
        when 11
          end_date.set(x)
        end
        puts "#{x} has been input"
        }
        #click_submit
        #if  $ie.contains_text('There is a problem with the
employee');click_submit;end
        click_new_employee_link
      }
    }
    end
  end

If you wanna connect directly to Excel, I will post some smaple code.

aidy



---------------------------------------------------------------------------------------------------------------
This message and any attachment are confidential and may be privileged or 
otherwise protected from disclosure. 
If you are not the intended recipient, please telephone or email the sender and 
delete this message and any attachment from your system.  
If you are not the intended recipient you must not copy this message or 
attachment or disclose the contents to any other person.
---------------------------------------------------------------------------------------------------------------
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to