Hi group, I was wondering if anyone could help me add something into this script that would get around the problem if no html table appears when running the script - so that it can continue it's loop. The postcode is invalid therefore no results are being returned in the table.
Many thanks in advance.... The script is as follows: require "watir-webdriver" browser = Watir::Browser.new :ff browser.goto "http://www.mycounciltax.org.uk/results? postcode=EX99AE&search=Search" content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]} require 'win32ole' application = WIN32OLE.new('Excel.Application') application.visible = TRUE workbook = application.Workbooks.Add(); worksheet = workbook.Worksheets(1); worksheet.visible row = 1; column = 0 content.each do |array| array.each do |element| worksheet.Cells(1,1).offset(row,column).value = element #.offset(row,column) column += 1 end row += 1 column = 0 end browser.goto "http://www.mycounciltax.org.uk/results? postcode=cv5+6bz&search=Search" content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]} row = 1; column = 0 content.each do |array| array.each do |element| worksheet.Cells(1,5).offset(row,column).value = element #.offset(row,column) column += 1 end row += 1 column = 0 end -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
