Hi Jim Still am getting the same error at this line
$ie.text_field(:name, "PolicyNumber").value = ($record ['PolicyNumber']) error: ./SearchInspection.rb:39:in `searchinspections': undefined method `[]' for nil:NilClass (NoMethodError) On Apr 1, 8:21 pm, Jim Matthews <jim_m...@swbell.net> wrote: > Shweta, > > $ie.text_field(:name, "PolicyNumber").set($record > ['PolicyNumber']) #error occured here > > If you are trying to put a value in a text_field, you need to use > value, so your line would look something like this: > > $ie.text_field(:name, "PolicyNumber").value = ($record > ['PolicyNumber']) > > Jim > > On Apr 1, 7:06 am, Shweta <nagman...@gmail.com> wrote: > > > > > Hi > > > Am getting error in the line where i put the comment has #error > > occured here > > > require 'win32ole' > > require 'watir' > > require 'Xls' > > > xlFile = XLS.new('C:\irma1.xls') #grab the data file in the same > > dirrectory > > myData = xlFile.getRowRecords('Inspection Search Data','Search') > > #pull data records from excel > > xlFile.close > > myData.each do |record| > > def searchinspections() > > $ie.link(:href, "http://searchrecord/ > > inspectionSearchInit.do").click > > $ie.button(:name, "clearCriteriaBtn").click > > $ie.radio(:index, 2).set > > $ie.text_field(:name, "PolicyNumber").set($record > > ['PolicyNumber']) #error occured here > > $ie.button(:name, "submitBtn").click > > if $ie.contains_text(record['ContainsText']) > > puts "Results of search: '#{record['PolicyNumber']}' contains > > '#{record['ContainsText']}'" > > else > > puts "Error: could not find text: '#{record['ContainsText']}' > > in results of search: '#{record['PolicyNumber']}'" > > end > > sleep 3 > > return $ie > > $ie.close > > end > > end > > > and am calling in other test as > > > require 'win32ole' > > require 'watir' > > require 'Login_irma' > > require 'test/unit/assertions' > > require 'watir/assertions' > > require 'SearchInspection' > > > $ie = login("mtedfhhh","password") > > $ie = searchinspections() > > > Can anyone suggest whats wrong here > > > On Apr 1, 2:41 pm, Shweta <nagman...@gmail.com> wrote: > > > > Hi > > > > Am trying to parameterizing my test cases am getting some error,am not > > > understanding where am wrong i have gone thru the posts regarding this > > > i dint get any idea,Can anyone pls let me know whats wrong here > > > > My code: > > > > require 'watir' > > > require 'watir/testcase' > > > require 'watir/assertions' > > > require 'test/unit' > > > require 'LogIn' > > > begin > > > xlFile = XLS.new('C:\\MA.xls') > > > > $Policynumber = xlFile.getColumnRecords('B4:C6', 'Ponumber') > > > setupInfo = xlFile.getHash('A1:B4', 'Setup') > > > $runTests = xlFile.getHash('A13:B27', 'Setup') > > > ensure > > > xlFile.close > > > end > > > > $test_site = setupInfo['URL'] > > > $UserName = setupInfo['Username'] > > > $UserPass = setupInfo['Password'] > > > > #get today's date for use in scripts > > > $today = "#{Time.now.month.to_s}/#{Time.now.day.to_s}/# > > > {Time.now.year.to_s}" > > > > # open the IE browser > > > $ie = Watir::IE.new > > > $ie.speed = :fast > > > # go to the selected MA site > > > $ie.goto($test_site) > > > > class TestSuite < Test::Unit::TestCase > > > include Watir::Assertions > > > > #login with the supplied producer username and password > > > def test_00Login > > > if $runTests['login'] == 'Yes' > > > if $ie.text.include?('Inspection Search Results') > > > login($Username, $Password) > > > else > > > puts 'The user was already logged in when the > > > application was opened.' > > > end > > > else > > > puts ' ' > > > puts 'You chose not to run the user login test.' > > > end > > > end > > > #Search records > > > def Searchrecord_ponumber > > > myData.each do |record| > > > $ie.link(:href, "http://www.searchrecord/SearchInit.do").click > > > $ie.button(:name, "clearCriteriaBtn").click > > > $ie.radio(:index, 2).set > > > $ie.text_field(:name, "policyNumber").set(record['PoNumber']) > > > $ie.button(:name, "submitBtn").click > > > > if $ie.contains_text(record['ContainsText']) > > > puts "Results of search: '#{record['PoNumber']}' contains '#{record > > > ['ContainsText']}'" > > > else > > > puts "Error: could not find text: '#{record['ContainsText']}' in > > > results of search: '#{record['PoNumber']}'" > > > end > > > sleep 3 > > > #~ ie.close > > > end > > > end > > > end > > > > Error message: > > > > Testrun.rb:37: > > > ./Xls.rb:226:in `getWorksheet': getWorksheet(sheet=Setup) --> Sheet > > > 'Setup' COULD NOT BE FOUND (RuntimeError) > > > from ./Xls.rb:193:in `getRange' > > > from ./Xls.rb:104:in `get2DArray' > > > from ./Xls.rb:145:in `getHash' > > > undefined method `close' for nil:NilClass (NoMethodError)- Hide quoted > > > text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---