开发者

What is ths error in Ruby Watir (WIN32OLERuntimeError: unknown property or method `document')?

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($hw开发者_高级运维nd,"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'


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?)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜