2

I have this code in Ruby waitr ..

$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'..') if $0 == __FILE__
require 'test/unit'
require 'Watir'
require 'Watir/contrib/enabled_popup'

class TC_Dialog_Test<Test::Unit::TestCase
  $ie=Watir::IE.new
  $ie.bring_to_front()
  $myDir = File.expand_path(File.dirname(__FILE__))

  def setup
    $ie.goto "file://#{$myDir}/aa.html"
  end
  def test_confirm_OK
     sleep(3)
    $ie.button(:id, 'btnConfirm').click_no_wait
    $hwnd = $ie.enable_popup(5)
    if ($hwnd)
      $popup =WinClicker.new
      $popup.makeWindowsActive($hwnd)
      sleep(3)
     # $popup.clickWindowsButton($hwnd,"OK")
      puts "you pressed Comfirm-ok"
      sleep(3)
    end 
  end
  end

when runnung this code get this error results ...

test_confirm_OK(TC_Dialog_Test):
WIN32OLERuntimeError: unknown property or method `document'
    HRESULT error code:0x800706b5
      The interface is unknown.
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:417:in `method_missing'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:417:in `document'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/container.rb:767:in `ole_inner_elements'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/container.rb:838:in `locate_input_element'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/input_elements.rb:10:in `locate'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:47:in `assert_exists'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:278:in `enabled?'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:53:in `assert_enabled'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:214:in `click_no_wait'
    Mo.rb:16:in `test_confirm_OK'
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
Adham
  • 63,550
  • 98
  • 229
  • 344
  • And? You expect us to debug your code? If I were you, I would try to post the minimal amount of code that causes the error. I would also post relevant HTML page. – Željko Filipin May 19 '11 at 08:10
  • @Zeljko: That was my reaction at first, but unless I've misunderstood the code, there's only six lines of code being executed before the error, and you can't really remove any of them. – Andrew Grimm May 19 '11 at 23:18
  • @Andrew: That just shows he or she did not put any effort in asking the question. I will put the same amount of effort in answering. – Željko Filipin May 20 '11 at 08:46
  • Hey at least they provided code, unlike some who seem to expect us to debug given no more info than "I try it and it doesn't work" – Chuck van der Linden May 21 '11 at 00:26
  • @Chuck. True. The only reason I left a comment is because I thought he or she put "some" effort in asking the question. – Željko Filipin May 23 '11 at 10:20
  • @Zeljko: How can someone both "not put any" and "put \"some\"" effort in? Is that like having tea and no tea? – Andrew Grimm Jun 07 '11 at 23:49
  • 1
    @Andrew: My first comment was wrong, it is obvious that there is some effort put in the question, but not enough for my taste. – Željko Filipin Jun 08 '11 at 07:38

2 Answers2

4

You are using Watir 1.5.3, but the current stable is 1.8.1. I suggest you to update your gem to the latest and try again. There is a good chance that the WIN32OLE object for IE has changed it's behavior and old gem is conflicting with it. (Have you updated IE or smth since last successful run?)

Laas
  • 5,978
  • 33
  • 52
0

I got the same error using Watir 1.8.1. I don't know if there is anything wrong with your code, but in my case the tests ran fine on other machines.

I am running my tests in RubyMine 3.1.x. Running RubyMine as Administrator allowed Ruby to have the rights to interact with IE properly and the problem went away.

Edit: Found the forum post which originally helped me solve the problem.

Randy Eppinger
  • 1,054
  • 13
  • 23