FireWatir Example Script

This is a simple example script. It opens yahoo mail and signs-in using the credentials you have given and then signs-out.

#Include the FireWatir file. 
require 'firewatir'

ff=FireWatir::Firefox.new
#Open yahoo mail. 
ff.goto("http://mail.yahoo.com")

#Put your user name. 
ff.text_field(:name,"login").set("User_Name")

#Put your password.
ff.text_field(:name,"passwd").set("Password")

#Click Sign In button.
ff.button(:value,"Sign In").click

#Click Sign Out button.
ff.link(:text, "Sign Out").click

#Close the browser.
ff.close
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Mar 17, 2009

    Kurt Liu says:

    On Ubuntu (8.10), I run into this problem when I try to require firewatir: irb...

    On Ubuntu (8.10), I run into this problem when I try to require firewatir:

    irb(main):001:0> require 'firewatir'
    LoadError: no such file to load -- firewatir
        from (irb):1:in `require'
        from (irb):1
    

    The solution seems to be to add this line before requiring firewatir:

    require "rubygems"
    

    Then you should have no more trouble.

    irb(main):002:0> require 'rubygems'
    => true
    irb(main):003:0> require 'firewatir'
    => true
    

    Found this from:

    http://groups.google.com/group/watir-general/browse_thread/thread/36eb143d853d00aa

  2. Mar 23, 2009

    dennisi says:

    @Kurt, I had the same problem. But I figured out that you don't have to include...

    @Kurt,

    I had the same problem. But I figured out that you don't have to include " require 'rubygems' " if you have it as an environment variable.

    The installer is supposed to do this, but it didn't for me when I followed the installation instructions on Watir's homepage.

     Add the following to your environment variables...

    Variable: RUBYOPTS

    Value: -rubygems