Sahi Pro - Ruby driver for Sahi
The Ruby driver for Sahi is available as a gem. http://rubygems.org/gems/sahiTo install:gem install sahi
This gem is a ruby client for the Sahi proxy. Sahi needs to be installed on your system for this to work.
If you are new to Sahi, read using sahi section to get familiar.
Have a look at sahi_test.rb in the sahi/ruby/ folder to see how this driver is used.
Full documentation is available as RDocs
A small example:
require 'test/unit'
require "sahi"
class SahiDriverTest < Test::Unit::TestCase
def setup
@browser = init_browser()
@browser.open
end
def teardown
if @browser
@browser.close
sleep(1)
end
def init_browser()
# Look at sahi/userdata/config/browser_types.xml to configure browsers.
@browser_name = "firefox"
return Sahi::Browser.new(@browser_name)
end
def test_google()
@browser.navigate_to("http://www.google.com")
@browser.textbox("q").value = "sahi forums"
@browser.submit("Google Search").click
@browser.link("Forums - Sahi - Web Automation and Test Tool").click
@browser.link("Login").click
assert @browser.textbox("req_username").exists?
end
end
Recording Ruby code
- Open sahi/config/sahi.properties and set controller.mode=ruby
- Restart Sahi
- Open a fresh browser with the proxy configured and navigate to any website.
- Press CTRL-ALT and DblClick on the page to bring up the Sahi Java Controller.
- Click on the record button and start performing actions on the browser. Steps will be visible in the "Recorded Steps" section.
- Copy the code from the Sahi console and paste it into your Ruby script.