Please find the updated script -
require 'watir'
include Watir
$excel_path = "D:/Data/dportalTestScripts/Product.xlsx"
$sheet_id = 1
$excel = WIN32OLE.new("excel.application")
$excel['Visible'] = true;
$workbook = $excel.Workbooks.Open $excel_path
$worksheet = $workbook.WorkSheets($sheet_id)
$worksheet.Select
ie = Watir::IE.new
ie.goto("http://test.com")
ie.text_field(:name, "userName").set("a")
ie.text_field(:name, "password").set('d')
ie.button(:value, "Login").click
ie.image(:name, 'toplogo_nav_08_off').click
ie.link(:text, "Manage Products").click
ie.link(:text, "Create Product").click
i = 1
until i > 3
ie.text_field(:name, "productName").set $worksheet.Range("a#
{i}").value
ie.button(:name, "submit_btn").click
if i == 3
break
end
i+=1
end
Thanks
Maumita
On Aug 11, 3:41 pm, John Kolokotronis <[email protected]> wrote:
> The local variable i in your last line isn't defined anywhere in your
> script...
>
> So: ie.text_field(:name, "productName").set $worksheet.Range("a#
> {i}").value)
>
> i isn't defined so no value is retrieved. If you are trying to
> retrieve a number of cells, you can do it with a for loop:
>
> for i in 1..5 # to get the first five cells...
> ie.text_field(:name, "productName").set($worksheet.Range("a#
> {i}").value) # Note the missing bracked in your original...
> end
>
> This is assuming the rest of your code is correct, which I haven't
> tested. You could try outputting the Excel values to the command line
> first to make sure you are getting the expected results - length is
> not your problem, the error simply is there because you are passing a
> nil value...
>
> Regards,
>
> John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---