The code that I have written is as shown below.When I try to run this
script,No Method Error is shown at the line where '#Error shown here'
is written.I have gone through various posts but am not able to figure
out the exact cause for this error.Please can anybody help me with
this.It is not able to figure out the 'jsclick' function when in fact
I have defined the function in the program itself.

This script is used to configure traps
require 'watir/ie'
require 'watir/WindowHelper'
require 'test/unit'
require 'win32ole'
require 'watir\contrib\enabled_popup'
require 'watir/assertions'

#include Watir::Assertions

$path='C:\Documents and Settings\chandrika.shenoy\Desktop\one.xls'

def elapsed(f,s)
time = (f-s).to_i
hours = time/3600.to_i
minutes = (time/60 - hours * 60).to_i
seconds = (time - (hours * 3600 + minutes * 60)).to_i
puts "Test Start "<<s.strftime("%H:%M:%S %m-%d-%y")
puts "Test Finish "<<f.strftime("%H:%M:%S %m-%d-%y")
puts "Test Time  << #{hours}hr#{minutes}min#{seconds}sec"

s=Time.now #System Time

def jsClick(a,button,k,user_input=nil)
 puts"function is called"
 hwnd1 = $ie.enabled_popup(waitTime) # wait up to 30 seconds for a
popup to appear
 puts "hwnd=#{hwnd1}"
   if (hwnd1)
      w = WinClicker.new
          popup_text = w.getStaticText_hWnd(hwnd1)
          puts "\n\nPOP TEXT =#{popup_text}\n\n"

excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Open($path)
worksheet = workbook.Worksheets(1) #get hold of the third worksheet

puts popup_text
puts"pop_text is in field"
puts"workbook is saved"
workbook.close  #Close the worksheet
puts"workbook is clsoed"
excel.quit              #Close Excel
puts"Excel quit"

   if ( user_input )
      w.setTextValueForFileNameField(hwnd1, "#{user_input}")
   sleep 3
                w.clickWindowsButton_hwnd(hwnd1, "#{button}")

#Define a variable
test_site = "mpxwebdemo.liebert.com"

#Open a browser

#increase the speed of execution
$ie.speed = :zippy

#Start of GXT Webcard testing
puts "Start of GXT Webcard Testing"

#Navigate to the website
puts "Step 1:  Navigate to the website"
$ie.goto test_site

#Click on configure tab
puts "Step 2:Click on Configure Tab"
$ie.frame(:index, 2).image(:id, 'imgConfigure').click

#Click on Access link
puts "Step 4:Click on Access tab"
$ie.frame(:index, 3).frame(:index, 2).link(:text,

#Start login
puts " Step   3: Begin Login"
                        # The "Sleep's below are here to slow down the 
just visibility
                        Watir.autoit.WinWait('Connect to 
                        #sleep 3
                        sleep 1
                        sleep 1
                        sleep 3

                        sleep 3
     #$ie.frame(:index, 2).image(:id, 'imgConfigure').click

     puts " Step   4: Login complete"

jsclick($ie,"OK")    #Error shown here.

#Click on Edit Button
puts "Step 5:Click on Edit button"
$ie.frame(:index, 3).frame(:index, 3).button(:id, 'editButton').click

#Click on Clear Button
puts "Step 6:Click on Clear Button1"
#$ie.frame(:index, 3).frame(:index, 3).button(:name, 'tC?1').click
$ie.frame(:index, 3).frame(:index, 3).button(:name, 'accessClear?

#Enter value in the 1st row 2nd column
puts "Step 7 :Enter the Network Name"
#$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpTraps').text_field(:name, 'tIpA?1').set('')
$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpAccess').text_field(:name, 'accessIpAddress?1').set('')
$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpAccess').text_field(:name, 'accessIpAddress?1').set

Enter value in 1st row 3rd column
puts "Step 8 :Enter the Port"
$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpTraps').text_field(:name, 'tP?1').set('162')

#Enter value in 1st row 4th column
puts "Step 9 :Enter the Community String"
#$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpTraps').text_field(:name, 'tCS?1').set('public')
$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpAccess').text_field(:name, 'accessCommunityString?1').set
$ie.frame(:index, 3).frame(:index, 3).form(:name,
'configSnmpAccess').text_field(:name, 'accessCommunityString?1').set

#Click on the Save Button
puts "Step 10:Click on the Save Button"
$ie.frame(:index, 3).frame(:index, 3).button(:name,'Submit').click

#Show test time information
puts "Step 11:Show test time information"
f = Time.now #elapsed finish time
elapsed( f, s) #elapsed time summary

puts "\n Step   12: Close IE "
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to