0

我有一个在 Firefox 中运行良好的脚本。

该脚本不在 Internet Explorer 中运行。我将不胜感激。

这是前几行:

require 'rubygems'
require 'watir'
require 'watir-webdriver'
require 'test/unit'

URL = "http://google.com/"

class TestGoogle < Test::Unit::TestCase
  def setup
    #@browser = Watir::Browser.new :firefox
    @browser = Watir::Browser.new :ie
  end

  def testSignInLink
    @browser.goto URL

以下是选定的错误消息:

C:\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)     C:/RubymineProjects/ditto/Google_01_TU_03.rb
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic/version.rb:3:             warning: already initialized constant VERSION
...
...
  1) Error:
testSignInLink(TestGoogle):
TypeError: superclass mismatch for class UnknownObjectException
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-    classic/exceptions.rb:12:in `<module:Exception>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-    classic/exceptions.rb:2:in `<module:Watir>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic/exceptions.rb:1:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic.rb:6:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic.rb:6:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:48:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:48:in `load_driver'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:40:in `load_driver_for'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:8:in `new'
C:/RubymineProjects/ditto/Google_01_TU_03.rb:11:in `setup'

第 11 行是:

@browser = Watir::Browser.new :ie
4

1 回答 1

0

根据@abe 评论,我做了以下事情。

仅对于 IE,我删除了“require 'watir'”。那工作得很好。

恢复“需要'watir'”。删除“需要'watir-webdriver'”。那工作得很好。

这就是我的问题的答案。但我不明白这一点。听起来这两个 API 是可以互换的 :)

于 2013-10-12T08:46:22.923 回答