Getting Started
Selenium-Ruby bundles the selenium server and Ruby classes in the gem so that you can use them right away.
Selenium Server
Selenium-ruby installs the executable at the ruby/bin directory so you can launch the server through command:
selenium
Selenium RC
You can use Selenium RC that is installed as a gem, so that your existing action based web testing still works. The following
example is using RSpec:
specify 'search hello world with google using interaction based script' do @page.open_page("/") @page.title.should == 'Google' @page.enter("q", "hello world") @page.click("btnG") @page.wait_for_load @page.title.should == 'hello world - Google Search' end
Selenium Ruby
You can use classes that come with Selenium ruby to write object based web testing.
specify'searh hello world with google using docmain based script' do page = GoogleHomPage.new(@webpage.browser) page.should be_present page.search_field.enter('hello world') page.search_button.click_wait page.title.should == 'hello world - Google Search' page.search_field.value.should == 'hello world' end
The class that described Google home page is defined as following
class GoogleHomPage < Selenium::WebPage def initialize(browser) super(browser, 'Google') end def title browser.get_title end def search_field text_field(:name, 'q') end def search_button button(:name, 'btnG') end end
