Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in running a simple watir script: uninitialized constant Watir::IE (NameError)

I have installed Ruby 2, devkit & Watir.

  • enviroment: OS win7(64bit)
  • installation files:
    • rubyinstaller-2.0.0-p0-x64.exe
    • DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe
  • part of gem list result:
    • commmonwatir 4.0.0
    • watir 4.0.0
    • win32-process 0.6.6

when I running a simple script:

require 'rubygems'
require 'watir'
require 'watir-webdriver' 
ie = Watir::IE.new
ie.goto("http://www.google.com")

I am getting the following error:

uninitialized constant Watir::IE (NameError)

then I tried ie = Watir::Browser.new instead of ie = Watir::IE.new still getting error:

cannot load such file watir-classic (loaderror)

then I tried installing watir-classic, getting error again:

extconf.rb
libxml2 is missing

Can anyone please help me resolve this issue?

like image 731
user2256777 Avatar asked Feb 16 '23 21:02

user2256777


1 Answers

Based on the error, my guess is that watir-classic is failing to install the nokogiri gem. Nokogiri does not currently support Ruby x64 on Windows - see https://github.com/sparklemotion/nokogiri/issues/864.

Two things you could try:

  1. Use 32bit Ruby (as suggested in the Nokogiri issue)

  2. Use a browser other than IE. By default, Browser.new will start IE using watir-classic. Using one of the other browsers will use watir-webdriver, which I do not believe is dependent on nokogiri.

Example:

require 'watir'
browser = Watir::Browser.new :chrome
browser.goto("http://www.google.com")
like image 86
Justin Ko Avatar answered Feb 19 '23 10:02

Justin Ko