由于未找到单一化方法,firefox 和 watir 无法在 Windows 上运行,这是怎么回事?

发布于 2024-09-16 09:56:02 字数 2903 浏览 6 评论 0 原文

我刚刚在 Windows XP SP3 32 位上安装了 ruby​​ 1.8.7 的全新副本。 安装 watir。

我使用了维基百科的例子:

require 'rubygems'

require 'watir/ie' 
Watir::Browser.default = 'ie'

b = Watir::Browser.new 
b.goto("http://www.google.com")

到目前为止一切顺利,按预期工作

,现在

require 'rubygems'

require 'watir/ie' 
Watir::Browser.default = 'firefox'

b = Watir::Browser.new 
b.goto("http://www.google.com")

抛出了一个丑陋的

C:\Documents and Settings\Administrator\Desktop>ruby watir2.rb
C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:89:in `
klass': undefined method `singularize' for "Buttons":String (NoMethodError)
        from C:/Ruby187/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/ele
ment_collections.rb:185
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir.rb:
29
        from (eval):1:in `klass'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/brows
er.rb:65:in `eval'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/brows
er.rb:89:in `klass'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/brows
er.rb:65:in `new'
        from watir2.rb:7

东西应该提到的是,我已经遵循了那里记录的过程 http://watir.com/installation/#win 此外,我认为这是不相关的,但我确实按预期安装了 jssh firefox 插件。

这个未定义的方法“singularize”代表什么?

下面是一些环境信息

C:\Documents and Settings\Administrator\Desktop>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby187/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: C:/Ruby187/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby187/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby187/lib/ruby/gems/1.8
     - C:/Documents and Settings/Administrator/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

C:\Documents and Settings\Administrator\Desktop>gem list

*** LOCAL GEMS ***

activesupport (3.0.0)
builder (2.1.2)
commonwatir (1.6.5)
firewatir (1.6.5)
hoe (2.6.1)
json_pure (1.4.6)
nokogiri (1.4.3.1 x86-mingw32)
rake (0.8.7)
rubyforge (2.0.4)
s4t-utils (1.0.4)
user-choices (1.1.6.1)
watir (1.6.5)
win32-api (1.4.6 x86-mingw32)
win32-process (0.6.2)
windows-api (0.4.0)
windows-pr (1.0.9)
xml-simple (1.0.12)

C:\Documents and Settings\Administrator\Desktop>

I just installed a fresh copy of ruby 1.8.7 on Windows XP SP3 32bits.
Install watir.

I used the wikipedia example :

require 'rubygems'

require 'watir/ie' 
Watir::Browser.default = 'ie'

b = Watir::Browser.new 
b.goto("http://www.google.com")

so far so good, works as expected

now

require 'rubygems'

require 'watir/ie' 
Watir::Browser.default = 'firefox'

b = Watir::Browser.new 
b.goto("http://www.google.com")

throws an ugly

C:\Documents and Settings\Administrator\Desktop>ruby watir2.rb
C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:89:in `
klass': undefined method `singularize' for "Buttons":String (NoMethodError)
        from C:/Ruby187/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/ele
ment_collections.rb:185
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir.rb:
29
        from (eval):1:in `klass'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/brows
er.rb:65:in `eval'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/brows
er.rb:89:in `klass'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/brows
er.rb:65:in `new'
        from watir2.rb:7

It should be mentioned that i have followed the procedure documented there http://watir.com/installation/#win
besides, I think it's unrelated but I do have the jssh firefox plugin installed as expected.

what's does this undefined method `singularize' stands for ?

below is some environment info

C:\Documents and Settings\Administrator\Desktop>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby187/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: C:/Ruby187/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby187/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby187/lib/ruby/gems/1.8
     - C:/Documents and Settings/Administrator/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

C:\Documents and Settings\Administrator\Desktop>gem list

*** LOCAL GEMS ***

activesupport (3.0.0)
builder (2.1.2)
commonwatir (1.6.5)
firewatir (1.6.5)
hoe (2.6.1)
json_pure (1.4.6)
nokogiri (1.4.3.1 x86-mingw32)
rake (0.8.7)
rubyforge (2.0.4)
s4t-utils (1.0.4)
user-choices (1.1.6.1)
watir (1.6.5)
win32-api (1.4.6 x86-mingw32)
win32-process (0.6.2)
windows-api (0.4.0)
windows-pr (1.0.9)
xml-simple (1.0.12)

C:\Documents and Settings\Administrator\Desktop>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

美男兮 2024-09-23 09:56:02

维基百科文章不是由 Watir 团队维护的,因此它可能不是最新的。请仅使用 watir.com 中的示例。

我查看了维基百科文章,但在任何地方都找不到 require 'watir/ie',请仅使用 require 'watir'

我已经安装了 Ruby 1.8.7-p302 来自 rubyinstaller.org/downloads 在完全修补的 XP SP3 32 位计算机上,并使用 gem 安装 watir

我已经安装了 Firefox 3.6.8Firefox 3.6 的 Windows 插件 来自 watir.com/installation

我已经执行了 watir.com/examples 中的代码,

require "rubygems"    
require "watir"
Watir::Browser.default = "firefox"
Watir::Browser.new

但我

NoMethodError: undefined method `demodulize' for "FireWatir::Pre":String
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:89:in `klass'
        from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/non_control_elements.rb:2
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir.rb:15
        from (eval):1:in `klass'
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:65:in `eval'
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:89:in `klass'
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:65:in `new'
        from (irb):4

真的很奇怪。这曾经有效。

如果你想用 Watir 驱动 Firefox,我建议 watir-webdriver gem 直到这个问题被修复。

Wikipedia article is not maintained by Watir team, so it is probably not up to date. Please use only examples from watir.com.

I took a look at Wikipedia article and I could not find require 'watir/ie' anywhere, please use just require 'watir'.

I have installed Ruby 1.8.7-p302 from rubyinstaller.org/downloads on a fully patched XP SP3 32 bit machine, and installed Watir with gem install watir.

I have installed Firefox 3.6.8 and Windows plugin for Firefox 3.6 from watir.com/installation.

I have executed code from watir.com/examples

require "rubygems"    
require "watir"
Watir::Browser.default = "firefox"
Watir::Browser.new

but I got

NoMethodError: undefined method `demodulize' for "FireWatir::Pre":String
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:89:in `klass'
        from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/non_control_elements.rb:2
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.5/lib/firewatir.rb:15
        from (eval):1:in `klass'
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:65:in `eval'
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:89:in `klass'
        from C:/Ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.5/lib/watir/browser.rb:65:in `new'
        from (irb):4

Really strange. That used to work.

If you want to drive Firefox with Watir, I would suggest watir-webdriver gem until this is fixed.

盗琴音 2024-09-23 09:56:02

只需在代码中的某处执行 require 'active_support' 即可。看起来这些人没有指定 active_support 作为依赖项。 在这里添加咆哮

Just do require 'active_support' somewhere in your code. Looks like the guys didn't specify active_support as dependency. add rant here

記憶穿過時間隧道 2024-09-23 09:56:02

适用于 1.8.6 (mingw) + active_support 2.3.8 + watir (尽管当我在 Firefox 中使用它时,我收到一条“请安装 jssh”消息)。

我的第一个预感是,gems 之间存在一些冲突,而 ruby​​gems“总是选择第一个”。

您可以安装 gem_conflict_checker gem(其中包括一个 ruby​​gems 插件来测试相同的情况)。安装它,然后安装 watir gem,它应该告诉您现有的冲突。

为了回答您原来的问题,这里是单数: http://blog.jayfields.com/ 2007/11/stringsingularize.html

-r

works for me with 1.8.6 (mingw) + active_support 2.3.8 + watir (though I get a "please install jssh" message when I use it with firefox).

My first hunch is that you have some conflict among gems, and rubygems "always chooses the first"

You could install the gem_conflict_checker gem (which includes a rubygems plugin to test for the same). Install it then install the watir gem and it should tell you of existing conflict.

In answer to your original question, here's singularize: http://blog.jayfields.com/2007/11/stringsingularize.html

-r

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文