Modified the code but now I am facing below error:

Inside Worksheet Loop
Fetching Row/Column Value 1 Keyword
Fetching Row/Column Value 2
Fetching Row/Column Value 3
Fetching Row/Column Value 4
Fetching Row/Column Value 6
Opening the Browser
Fetching Row/Column Value 1 Keyword
Fetching Row/Column Value 2
Fetching Row/Column Value 3
Fetching Row/Column Value 4
Fetching Row/Column Value 6
C:/Ruby187/lib/ruby/gems/1.8/gems/watir-2.0.4/lib/watir/DataDriven.rb:
53: uninit
ialized constant Object_Prop_Name (NameError)
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-2.0.4/lib/watir/
DataDriven.
rb:34:in `each'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-2.0.4/lib/watir/
DataDriven.
rb:34
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-2.0.4/lib/watir/
DataDriven.
rb:28:in `each'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-2.0.4/lib/watir/
DataDriven.
rb:28



New Code snippet:


#Include The Library
require 'rubygems'
require 'win32ole'
require 'watir'
require 'watir/ie'
require 'element_collections'
require 'screen_capture'
require 'watir/browser'


#Browser = Watir::Browser.new
#Watir::Browser.default = 'ie'

$Keyword = ""
$Object_Prop_Name = ""
$Object_Prop_Value = ""
$Expected_Output = ""
$Parm_01 = ""


begin

#Open Excel File
excel = WIN32OLE::new('excel.Application')
excel.DisplayAlerts = false
workbook = excel.Workbooks.Open('C:\Users\amanpreet.oberoi\Desktop
\Google.xls')
#Loop through the worksheets
for i in 1 .. workbook.Worksheets.Count

puts "Inside Worksheet Loop"
  worksheet = workbook.Worksheets(1)
  rowcount = worksheet.UsedRange.Rows.Count

  for j in 2..rowcount
    $Keyword =worksheet.Cells(j, 1).value
    puts "Fetching Row/Column Value 1 Keyword"
    $Object_Prop_Name = worksheet.Cells(j, 2).value
    puts "Fetching Row/Column Value 2"
    $Object_Prop_Value = worksheet.Cells(j, 3).value
    puts "Fetching Row/Column Value 3"
    $Expected_Output = worksheet.Cells(j, 4).value
    puts "Fetching Row/Column Value 4"
    $Parm_01 = worksheet.Cells(j, 6).value
    puts "Fetching Row/Column Value 6"

    case $Keyword
      when /^OpenURL/
      @Browser=Watir::IE.start($Parm_01)
      puts "Opening the Browser"
      @Browser.maximize

      when /^SetText/
      @Browser.text_field(:"#{Object_Prop_Name}",
Object_Prop_Value).set(Parm_01)

      when/^ClickButton/
      @Browser.button(:"#{Object_Prop_Name}", Object_Prop_Value).click

     when/^ClickLink/
    @Browser.link(:"#{Object_Prop_Name}", Object_Prop_Value).click

    when/^CloseURL/
    @Browser.close

    when/^Result/
    Actual_Output=verify_text(Expected_Output,"Pass","Fail")
    worksheet.Cells(j, 5)['Value']=Actual_Output
    time_stamp_s = Time.new.strftime('%m%d_%H%M_%S')
    screenshot_filename="#{time_stamp_s}_#{Expected_Output}"+"\.jpg"
    screen_capture(screenshot_filename,active_window_only=false,
save_as_bmp=false)
    worksheet.Cells(j, 7)['Value']=screenshot_filename
    workbook.SaveAs('C:\Users\amanpreet.oberoi\Desktop\Google.xls')
    else
      "Exit"
    end

  end

end
 workbook.Close()
excel.quit()

end





C:\Ruby187\lib\ruby\gems\1.8\gems\watir-2.0.4\lib\watir>

On Jan 23, 10:19 am, Amanpreet Singh Oberoi <ama...@gmail.com> wrote:
> Excel file containing is kept at my path mentioned in script.
>
> workbook = excel.Workbooks.Open('C:\\Users\\amanpreet.oberoi\\Desktop\
> \Google.xls')
>
> Excel file sample attached with this mail.
>
> Thanks,
> Amanpreet
>
>
>
>
>
>
>
> On Sun, Jan 22, 2012 at 10:23 PM, Dave McNulla <mcnu...@gmail.com> wrote:
> > Where is your script (contents of google.xls)? Maybe you forgot OpenURL.
>
> > Dave
>
> >  --
> > Before posting, please readhttp://watir.com/support. In short: search
> > before you ask, be nice.
>
> > watir-general@googlegroups.com
> >http://groups.google.com/group/watir-general
> > watir-general+unsubscr...@googlegroups.com
>
>
>
>  Google.xls
> 37KViewDownload

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to