views:

201

answers:

3

Hi there,

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>
A: 

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.

Željko Filipin
mmm interestingi tried withrequire "rubygems"require "watir-webdriver"browser = Watir::Browser.new(:firefox)browser.goto("http://www.google.com")and alsorequire "rubygems"require "watir-webdriver"browser = Watir::Browser.new(:ie)browser.goto("http://www.google.com")in both cases, i get watir3.rb:3: uninitialized constant Watir (NameError)wtf ???
I have just tried your code and it works at my machine. Really strange. Uninstall Ruby and try installing it with only watir-webdriver. Not sure if that would help, but you could try.
Željko Filipin
A: 

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

Tass
i think i tried this one without success
Put it right after `require 'rubygems'`
Tass
didnt work. i tried right after require 'rubygems', in the failiing firewatir file, i try inside the module, outsite, reverse order or 'rubygems' and 'active_support'none of that worked :'(
Error report would be useful. And `rubygems` needs to be first.
Tass
basically the reported error is just the same: undefined method `singularize'
A: 

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

rogerdpack
how come i have a gem conflict ? i used a fersh windows totally clean (never saw any ruby binary before), installed a fresh 1.8.7 with the one click installer (the lastest one as of yesterday or so), then issued a gem update (nothing to update), then gem install watir.and i can seriously get a gem conflict with that? (sorry if the question feels bump...)will try gem_conflict_checker asap