Hello guy, first of all, excuse me for my english which is not my mother language.
The first step we need to do when installing Watir is install Ruby. We need to do this because Watir uses Ruby to do his magic.
Installing Ruby
Download the ruby installer from here. For this tutorial we will use Ruby 1.9.3-p392
Lets install ruby.
Find the rubyinstaller-1.9.3-p392.exe we just downloaded and double click it.
Select your language and accept the conditions
Set your installation path, in my case, P:\Ruby\Ruby193 and check all the options.
Its useful to check at least the second and third options:
Add Ruby executables to your PATH: allow us to run ruby scripts at the command promp just typing something like this:
ruby hello.rbAssociate .rb and .rb with this Ruby installation: make the ruby files (.rb) look like this
and not like this
Click Install
Click Finish
Testing Ruby
If we want to check our ruby installation, we could open a console: Start > run > cmd and type
ruby --version
You should see something like this
Installing the Developer Kit
Next thing we need to do is install the ruby developer kit. You can get it here. This toolkit makes easy to build and use native C/C++ extensions such as RDiscount and RedCloth for Ruby on Windows.
The question is...which Development Kit?
There are several and different versions of Development Kits (DevKit). Download the right one for your version of Ruby:
- Ruby 1.8.6 to 1.9.3: tdm-32-4.5.2
- Ruby 2.0.0: mingw64-32-4.7.2
- Ruby 2.0.0 x64 (64bits): mingw64-64-4.7.2
To install the development kit follow this steps:
While installation is (in general) simple, please ensure you carefully follow each step below.
1. Preparation
- If you previously installed the legacy DevKit
devkit-3.4.5r3-20091110.7z
, its artifacts were extracted into each Ruby installation and need to be manually removed. Remove thegcc.bat, make.bat, and sh.bat
stub batch files in
and the\bin
subdirectory for each Ruby installation using the legacy DevKit.\devkit
- If you previously installed one of the legacy self-extracting DevKit’s, follow the SFX DevKit upgrade instructions.
2. Download Files (If you haven't done this one )
- The current DevKit is available at the RubyInstaller download page with older versions available at the archives page. As backup, check our GitHub downloads page.
3. Create a directory for the DevKit installation
- The one i have choosen is P:\Ruby_Development_Kit
4. Extract Files
- Left double-click the self-extracting executable (SFX) downloaded from Step 2 and choose a directory (without spaces) to install the DevKit artifacts into. For example,
P:\Ruby_Development_Kit
. NOTE: the SFX is really a 7-Zip archive with a bit of embedded magic. If you already have 7-Zip installed, you can simply right-click it and extract its contents as you would a normal 7z archive.
4. Run Installation Scripts
- Open a console Start > run > cmd
cd P:\Ruby_Development_Kit
from Step 3 above.
Note that because our DevKit installation was made in a different drive than C: which is the default drive went we start the command prompt, we need to change the drive we are working with. Just type P: and hit Enter
Now we can "move" to the DevKit installation directory. Type cd P:\Ruby_Development_Kit and Enter
- Run the the command
ruby dk.rb init
to generate theconfig.yml
file to be used later in this Step. Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at present).
We should now have a config.yml file in P:\Ruby_Development_Kit
You could open it using Notepad or you favorite text editor
You should see something like this
# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- P:/Ruby/Ruby193
- Edit the generated
config.yml
file to include installed Rubies not automagically discovered or remove Rubies you do not want to use the DevKit with. - [optional]
ruby dk.rb review
to review the list of Rubies to be enhanced to use the DevKit and verify the changes you made to it are correct. - Finally,
ruby dk.rb install
to DevKit enhance your installed Rubies. This step installs (or updates) anoperating_system.rb
file into the relevant directory needed to implement a RubyGemspre_install
hook and adevkit.rb
helper library file into
.\lib\ruby\site_ruby
NOTE: you may need to use the
--force
option to update (with backup of the originals) the above mentioned files as discussed at the SFX DevKit upgrade FAQ entry.
And we get this
Testing Developer Kit
- Confirm your Ruby environment is correctly using the DevKit by running
gem install json --platform=ruby
. JSON should install correctly and you should seewith native extensions
in the screen messages.
- Next run
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
to confirm that the json gem is working.
Installing Watir
The last thing to do installing Watir, is execute the following commands. Lest do it !!
gem update --system
gem install watir
To acelerate download, you could use the following command, but you will not install RDoc and ri.
gem install watir --no-rdoc --no-ri
gem update --system --no-rdoc --no-ri
Testing Watir
Open a the command prompt (Start > run > cmd) and type irb, which stands for Interactive Ruby Shell
Now we can create an "instance" of our browser (IE by default). Watir::Browser.start("http://www.google.com")
An Internet Explorer window should appear white the google page.
3 comentarios
Write comentariosme sale este error en la parte final de la instalcion ya busque como arreglarlo pero no encuentro nada me puede ayudar?
Replyirb(main):002:0> Watir::Browser.start("http://www.google.com")
LoadError: cannot load such file -- watir-classic
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54
:in `require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54
:in `require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-5.0.0/lib/watir/loader
.rb:41:in `load_driver'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-5.0.0/lib/watir/loader
.rb:33:in `load_driver_for'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-5.0.0/lib/watir/loader
.rb:14:in `start'
from (irb):2
from C:/Ruby22-x64/bin/irb:11:in `'
irb(main):003:0>
Hola Ivan, me puedes indicar en version de windows estas haciando la prueba y si es de 32 o 64 bits. Gracias
Reply
ReplyIt is nice blog Thank you provide important information and i am searching for same information to save my time Ruby on Rails Online Training India