This is really poorly written and more of a mind dump than anything. Use it at your own risk. I eventually gave up on cygwin. It caused me some headaches. Instead, I did the following:
1. Installed ruby for windows using the one-click installer from ruby-lang.org (for some reason I had to install under the Administrator account on my windows machine)
2. Installed
windows console 2.0. It beats using the dos command, but it still is poor compared to the *nix command line.
# helpful commands cd (just like *nix) dir (similar to ls -al in *nix)
3. Opened up console and typed:
irb puts 'hello world' exit
Good, ruby seems to be working.
3. Installed intype as my text editor of choice.
4. Installed watir
gem install watir
5. Then after trying watir, I wasn’t really all that happy with it so I decided to go with using a combination of mechanize and hpricot. See useful scripts with mechanize and hpricot.
—
—
Mind dump
—
1. Install ruby for windows (use the ruby one-click installer from ruby-lang.org) (i just installed to c:\ruby. it will take about 5 minutes to complete the installation. while you’re waiting download intype or your text editor of choice for windows. e-texteditor comes recommended but will cost you $30 bucks.) Don’t do any of this or your cygwin with ruby will not function correctly.
2. Install cygwin (this will emulate *nix-like command terminals. The windows dos command console is a pain to work in and most all the examples you will find online are for *nix)
a. Download the setup.exe from Cygwin.com and then run setup.exe
b. Install in c:\cygwin
c. Install the local package directory to your desktop
d. Install from direct connection
e. Choose an available download site and press next
f. For the Select Packages make sure you do the following:
i. Go to Devel -> ruby, and change ‘Skip’ to 1.8.7 by clicking on the ‘Skip’ on the ruby line (here’s a tutorial with screenshots (but ignore the packages being installed. they won’t apply to you.))
ii. Go to Devel -> and install all the lines that start with gcc by once again clicking on the prospective line’s ‘Skip’
iii. Go to Devel -> make and install by doing the same as above
iv. Go to Devel -> openssl-devel and install by doing the same as above
v. Under Database -> sqlite you might as well do the same since if you run rails one day you’ll want it
vi. Under Net -> openssl install
vii. Under Net -> openssh install
viii. Under Editors -> vim install
ix. Under Editors -> nano install
x. Under Net -> curl install
xi. Under Shells -> rxvts install all of them
xii. Under System -> ping install
xiii. Under Web -> wget install
g. Then click next and wait for everything to download. It will probably take about 10 minutes.
Open up Cygwin and type in the prompt:
irb puts 'hello world' exit
As long as that didn’t throw any errors than your ruby is setup correctly. Time to get watir. Wait first we have to install rubygems.
3. Install ruby gems
a. Go to the rubyforge ruby gems installation page and download the latest version as a tgz file. (rubygems-1.2.0.tgz at the time of this writing)
b. Save this file to My computer c:\cygwin\home\user name\sources (you’ll need to create the directory sources)
c. Open up cygwin and do the following
cd ~/sources tar -pxzf rubygems-1.2.0.tar cd rubygems-1.2.0 ruby setup.rb
4. Install watir
gem install watir
Scott,
Thank you for the mind dump.
It was all good until I tried to test watir.
I ran the following script….
# Here we see a very simple WATIR script to drive to google (testgoogle.rb) and validate a page
require ‘rubygems’
require ‘watir’ # use watir gem
test_site = ‘http://www.google.com’ # set a variable
ie = Watir::IE.new # open the IE browser
ie.goto(test_site) # load url, go to site
ie.text_field(:name, “q”).set(”pickaxe”) # load text “pickaxe” into search field named “q”
ie.button(:name, “btnG”).click # “btnG” is the name of the Search button, click it
if ie.text.include?(”Programming Ruby”)
puts “Test Passed. Found the test string: ‘Programming Ruby’.”
else
puts “Test Failed! Could not find: ‘Programming Ruby’”
end
… and got this error:
$ ruby testgoogle.rb
/usr/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/win32.rb:9:in `initialize’: LoadLibrary: \usr\lib\ruby\gems\1.8\gems\wat
ir-1.5.6\watir\IEDialog\Release\IEDialog.dll (RuntimeError)
from /usr/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/win32.rb:9:in `new’
from /usr/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/win32.rb:9
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from /usr/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir.rb:85
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require’
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require’
from testw.rb:2
Any ideas on how to fix that?
Thanks!
Frank
hmm. It could be a few things, but my first guess is it might be cygwin. I had a lot of problems with it. I didn’t mention it in the post, but I actually ended up uninstalling it and just learning how to use the windows dos commands.
Your script worked great.
Here’s what I used adapted from your script on my mac.
require ‘rubygems’
require ’safariwatir’ # use watir gem
test_site = ‘http://www.google.com’ # set a variable
ie = Watir::Safari.new # open the IE browser
ie.goto(test_site) # load url, go to site
ie.text_field(:name, “q”).set(”pickaxe”) # load text “pickaxe” into search field named “q”
ie.button(:name, “btnG”).click # “btnG” is the name of the Search button, click it
if ie.text.include?(”Programming Ruby”)
puts “Test Passed. Found the test string: ‘Programming Ruby’.”
else
puts “Test Failed! Could not find: ‘Programming Ruby’”
end
How did you install Rails in Windows? InstantRails, RailsStack, manually??? Did you get Rails 2.1.0 installed or an older version?
Thank you, again, for your insights.
I used InstantRails. I’m pretty sure it was Rails 2.1.