Search This Blog

Thursday, September 17, 2009

Steps Ruby on Watir

step 1:

install ruby first : [ruby 186-27]
http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe

For ex:
you install in c:/ruby

place mouse pointer on my computer -> right click -> properties -> advance -> environment variables ->
select path [ edit ] add at last
;c:\ruby\bin;

step 2:
Open command prompt by click Start -> run -> cmd
cd\
cd c:\ruby

step 3:
type : "gem install watir" to install watir

c:\ruby> gem install watir


step 4:
create a file with extension .rb , for ex: sample.rb
save it in c:\ruby
go to that dir and type

step 5:
type to run ruby filename.rb

c:\ruby>ruby sample.rb



here is the sample code , open note pad and paste this code "red color text's" and save as sample.rb
which can run google.co.in and type in text box and click search button

require 'watir'
require 'test/unit'

class TC_article_example < Test::Unit::TestCase
def test_search
browser = Watir::Browser.new
browser.goto("http://www.google.com/ncr")
browser.text_field(:name, "q").set("pickaxe")
browser.button(:value, "Google Search").click
assert(browser.text.include?("Programming Ruby: The Pragmatic Programmer's Guide"))
end
end





ex link
http://www.secretgeek.net/watir_3mins.asp
http://showmedo.com/videotutorials/video?name=7580000&fromSeriesID=758

No comments:

Hit Counter


View My Stats