Ruby_Installation_Error_Watir
Asked Answered
M

3

5

I'm running into the following error:

#ERROR
C:\Users\Farooq>D:

D:\>irb
irb(main):001:0> require 'rubygems'

=> false

irb(main):002:0> require 'watir'

LoadError: cannot load such file -- watir/loader
        from D:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from D:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from D:/Ruby193/lib/ruby/gems/1.9.1/gems/commonwatir-4.0.0/lib/watir.rb:1:in `<top (required)>'
        from D:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
        from D:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
        from D:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
        from (irb):2
        from D:/Ruby193/bin/irb:12:in `<main>'
irb(main):003:0>

I have installed the gem watir and my system configurations are as follows:

  • OS:Windows7
  • IE:10
Marrero answered 5/10, 2013 at 16:24 Comment(8)
can you do gem list --local and show the output here?Rustcolored
D:\>gem list --local *** LOCAL GEMS *** bigdecimal (1.2.1, 1.1.0) childprocess (0.3.9) commonwatir(4.0.0) ffi(1.9.0 x86-mingw32) io-console(0.4.2, 0.3) json(1.8.0, 1.5.5) mini_portile(0.5.1) minitest(5.0.8, 2.5.1) multi_json(1.8.1) rake(10.1.0, 0.9.2.2) rdoc(4.0.1, 3.9.5) rubyzip(1.0.0, 0.9.9) selenium-webdriver (2.35.1) watir-webdriver (0.6.4) websocket(1.1.1, 1.0.7) win32-api 1.5.0 universal-mingw32) win32-process (0.7.3) windows-api(0.4.2) windows-pr(1.2.2)Marrero
@Marrero did you install watir gem correctly? if you are getting same error with firefox . try to install watir gem again .try gem install watir --systemSamaveda
@prashantsharma why gem install watir --system is needed.. please don't advice him this... Let him understand how to use watir-webdriver..Rustcolored
It worked for me with firefox.Samaveda
hey prashanth can u tell me like how to access the element on gmail(account create page ) which has Birthday (month) it tried with all the valid html elements but unable t o identify itMarrero
please post new question for this . , I shall tell you then.Samaveda
yaa i did that pleaase look into itMarrero
R
1

Okay! so looking at the output of gem list --local I can surely tell you that you installed watir-webdriver,not the watir gem.

You should write it as require 'watir-webdriver'. You also don't need to require 'rubygems',as you are in Ruby1.9.3.

Here is a simple code using chrome:

require 'watir-webdriver'
b = Watir::Browser.new :chrome
b.goto 'https://www.google.co.in/'
b.text_field(:id => 'gbqfq').set 'ruby'
Rustcolored answered 5/10, 2013 at 16:37 Comment(16)
D:\>irb irb(main):001:0> require 'watir-webdriver' => true irb(main):002:0> ie=Watir::IE.start 'www.gmail.com' NameError: uninitialized constant Watir::IE from (irb):2 from D:/Ruby193/bin/irb:12:in `<main>' irb(main):003:0> when i do that iget the above errorMarrero
@Marrero You are using watir-webdriver gem,not watir.. Notice that.Rustcolored
so wat next i mean i can open the browser through webdriverMarrero
browser=Watir::Browser.new :chrome even i tried with the baive statements but i get the error can u please help me outMarrero
irb(main):004:0> browser=Watir::Browser.new :chrome Selenium::WebDriver::Error::WebDriverError: Unable to find the chromedriver exec utable. Please download the server from code.google.com/p/chromedriver/do wnloads/list and place it somewhere on your PATH. More info at code.googl e.com/p/selenium/wiki/ChromeDriver. from D:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/s elenium/webdriver/chrome/service.rb:20:in executable_path' from D:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/chrome/service.rb:33:in default_service'Marrero
@Marrero do you have firefox ? Then try that.. for chrome and IE I think some extra installation you need to do..Rustcolored
@Marrero Did you try b = Watir::Browser.new :firefox ? It should work if you have installed firefox...Rustcolored
@Marrero did you install watir gem correctly? if you are getting same error with firefox . try to install watir gem again .try gem install watir --systemSamaveda
@prashantsharma OP wanted to use watir-webdriver.. Don't make him confuse with the new gem.. :) to use watir-webdriver,gem install watir-webdriver enough..Rustcolored
thanks arup its working fine for firefox can u please tell me like what are the extra setings to be done for IE and CHROMEMarrero
@Marrero I would suggest you to go with Firefox,as it is cool. But if you want chrome,then here you get the file to download.Rustcolored
one more question like without using watir-webdriver how can i navigate to browser using just WatirMarrero
hey arup how can u tell me like how to access the link in gmail(account create page),which contains BIRTHDAY(month)i tried with all the possible and valid html elementsMarrero
hey can u please tell me how to accept the answer i started using it recentlyMarrero
hey done arup i have accepted by the way what kind of benefit do u receive if i accept it ,do replyMarrero
k cool thats great hey can u tell which command is used to maximize the browserMarrero
C
6

Make sure watir gem is installed correctly. You can do it like this:

gem install watir

Ignore the other answers here which say that you should not install watir - it is perfectly normal to install watir since this is a meta gem, which will load watir-webdriver or watir-classic as needed.

And then in your code, do like this:

require "watir"

b = Watir::Browser.new :chrome # loads watir-webdriver and opens up a Chrome browser

However, if you do not specify the browser, then default will be used for current platform.

# on Windows
b = Watir::Browser.new # loads watir-classic and opens up an IE browser

# on unix
b = Watir::Browser.new # loads watir-webdriver and opens up a Firefox browser

In other words - using a watir gem is perfectly normal even if you'd like to use watir-webdriver underneath it because you can switch the drivers really easily.

You can read more from the watir readme.

Catercousin answered 5/10, 2013 at 21:50 Comment(1)
when I say gem install watir I got the following error "unable to build native gem extension nmake is not recognized as internal or external command".Marrero
R
1

Okay! so looking at the output of gem list --local I can surely tell you that you installed watir-webdriver,not the watir gem.

You should write it as require 'watir-webdriver'. You also don't need to require 'rubygems',as you are in Ruby1.9.3.

Here is a simple code using chrome:

require 'watir-webdriver'
b = Watir::Browser.new :chrome
b.goto 'https://www.google.co.in/'
b.text_field(:id => 'gbqfq').set 'ruby'
Rustcolored answered 5/10, 2013 at 16:37 Comment(16)
D:\>irb irb(main):001:0> require 'watir-webdriver' => true irb(main):002:0> ie=Watir::IE.start 'www.gmail.com' NameError: uninitialized constant Watir::IE from (irb):2 from D:/Ruby193/bin/irb:12:in `<main>' irb(main):003:0> when i do that iget the above errorMarrero
@Marrero You are using watir-webdriver gem,not watir.. Notice that.Rustcolored
so wat next i mean i can open the browser through webdriverMarrero
browser=Watir::Browser.new :chrome even i tried with the baive statements but i get the error can u please help me outMarrero
irb(main):004:0> browser=Watir::Browser.new :chrome Selenium::WebDriver::Error::WebDriverError: Unable to find the chromedriver exec utable. Please download the server from code.google.com/p/chromedriver/do wnloads/list and place it somewhere on your PATH. More info at code.googl e.com/p/selenium/wiki/ChromeDriver. from D:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/s elenium/webdriver/chrome/service.rb:20:in executable_path' from D:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/chrome/service.rb:33:in default_service'Marrero
@Marrero do you have firefox ? Then try that.. for chrome and IE I think some extra installation you need to do..Rustcolored
@Marrero Did you try b = Watir::Browser.new :firefox ? It should work if you have installed firefox...Rustcolored
@Marrero did you install watir gem correctly? if you are getting same error with firefox . try to install watir gem again .try gem install watir --systemSamaveda
@prashantsharma OP wanted to use watir-webdriver.. Don't make him confuse with the new gem.. :) to use watir-webdriver,gem install watir-webdriver enough..Rustcolored
thanks arup its working fine for firefox can u please tell me like what are the extra setings to be done for IE and CHROMEMarrero
@Marrero I would suggest you to go with Firefox,as it is cool. But if you want chrome,then here you get the file to download.Rustcolored
one more question like without using watir-webdriver how can i navigate to browser using just WatirMarrero
hey arup how can u tell me like how to access the link in gmail(account create page),which contains BIRTHDAY(month)i tried with all the possible and valid html elementsMarrero
hey can u please tell me how to accept the answer i started using it recentlyMarrero
hey done arup i have accepted by the way what kind of benefit do u receive if i accept it ,do replyMarrero
k cool thats great hey can u tell which command is used to maximize the browserMarrero
L
0

got the same issue, what i did was clean all gems beside the default gem come with ruby by running "gem uninstall --all " and run "bundle install" using gemfile.

Loveinidleness answered 24/3, 2019 at 21:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.