Hi~

Thank you.
I already check this. It is working fine.
here is the entire source code.

require 'watir'
require 'win32ole'
require 'thwait'

inputFile = "C:\\codework\\watir\\Qian\\in.txt"
logfile = "C:\\codework\\watir\\Qian\\logfile.txt"
testCaseFile = "C:\\codework\\watir\\Qian\\Book1.xls"



#def getTestCases(testCaseFile)
  testCase = Array.new # testCase - the array [i1, i2, answer]
  testCases = Array.new # array of testCases
  xl=WIN32OLE.new('Excel.Application')
  xl.Workbooks.Open(testCaseFile)

  data = false
  testCaseNumber = 0
  i = 1
  while (true)

          if (xl.Cells(i,1).value == "End data")
            break
          end
          if (xl.Cells(i,1).value == "Start data")
            data = true
            i+=1
          end

          if (data)
            ans = xl.Cells(i,3).value
            ansStr = ans.to_s
              if /(^.*)\.0$/ =~ ansStr
                ansStr = Regexp.last_match(1)
              end
            testCase = [xl.Cells(i,1).value,ansStr]
            testCases[testCaseNumber] = testCase
            testCaseNumber += 1
          end
    i += 1
  end

  xl.Workbooks.Close

#end

k =testCaseNumber

fileHandle = File.open(logfile,"w")
infile = File.new(inputFile, "r")
fileHandle << "Test result are:\n\n"
folderLocation = "http://localhost:81/Homework/";

infile.each{
  |i|
  thisLocation = folderLocation, i
  print thisLocation
  k =testCaseNumber
  while k !=0
    ie = Watir::IE.new
    ie.goto(thisLocation)
    tcase= testCases[k-1]
    arg1= tcase[0]
    ans = tcase[1]
    puts tcase[0]+"......"+tcase[1]
    ie.textField(:name, "Fahrenheit").set(arg1.to_s)
    ie.button(:value, "transfer").click
    if ie.contains_text(ans.to_s)
      fileHandle << ":::Passed\n\n"
    else
      fileHandle << ":::failed\n\n"
    end
    #testCases = getTestCases(testCaseFile)
    k-=1
  end
}

fileHandle.close


when I run this code it first open a blank ie page, and then the error
happens.
can anyone get me out of this?
Thank you all with pleasure

Allen


On Sun, Apr 12, 2009 at 5:25 AM, Tony <ynot...@gmail.com> wrote:

>
> Hi Allen,
>
> This is an OLE error.
> Seems like ie = Watir::IE.new didnt connect to the IE com.
> Hence couldnt find the navigate method of the com object.
>
> This occurs sometimes ... a restart might fix this.
> If not you would have to check your ruby installation -
>
> try the below from irb-
> require 'win32ole'
> ie = WIN32OLE.new('InternetExplorer.Application')
> ie.Navigate('http://google.com')
>
> Check if the above is working ... ??
>
> Thanks,
> Tony
>
> >
>


-- 
There are some things in this world will never change and some things do
change.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to