Selenium On Rails
December 12, 2008
Getting Started
Selenium on Rails is the name of the Selenium product crafted specifically for Rails
developers and is distributed as a Rails plugin. It has been designed to work seamlessly
with the Rails testing environment and fixtures.
It’s easy to install Selenium on Rails and get started.
1. Install the core Selenium files needed by the plugin:
SAMPLE>gem install selenium
2. Install the Selenium on Rails plugin for a given project:
SAMPLE>ruby script/plugin install http://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails/
3. Generate the test directory and a test script:
SAMPLE>ruby script/generate selenium first.rsel
4. Start your Rails server in its test environment:
SAMPLE>ruby script/server -e test
5. Open the Selenium Test Runner in your browser:
http://localhost:3000/selenium
If your installation and setup succeeded, you see the Selenium Test Runner in your browser. You should also know that Selenium tests can be run from the command line and integrated into an automated suite of tests, but for demonstration purposes we will use the built-in web interface to execute our tests.
SAMPLE/test/selenium/first.rsel
setup
open ‘/’
assert_title ‘Ruby on Rails: Welcome aboard’
Run test in –> http://localhost:3000/selenium
For more reference –> http://seleniumhq.org/
Regards,
P.Raveendran
Will Paginate — Plugin
September 29, 2008
Will Paginate:
1. Installation:
cmd>git clone git://github.com/mislav/will_paginate.git
2. Git Installation
You don’t have git installed already then install it
Install git from here.
3. Try with this Basic Code:
a. Product model(products Table) contains these fields
id
name
price
description
b. DB has 100 records
c. controller:
def productlist
@products = Product.paginate :page => params[:page]
end
d. productlist.hml.erb
<%= will_paginate @products %>
<ul>
<% @products.each do |c| %>
<li><%= c.id %> – <%= c.name %> – <%= c.price %> – <%=
c.description %></li>
<% end %>
</ul>
Output looks Like:
Links for more help –> http://agilewebdevelopment.com/plugins/will_paginate
Active scaffold – Rails plugin
July 7, 2008
Active Scaffold
Active scaffold is rails plugin used for,
Create,Edit,Update,delete,Search and sorting records in Ajax.
If you want to install it in your rails application then,
1. Please follow this url –> Active Scaffold
2. Install git in your computer –> Git
Ferret in rails
December 15, 2007
View
<%= start_form_tag :action => ’search_number’ %>
<div align=”center”>
<h3>Search Phonenumber By</h3>
<table>
<tr>
<td><select name=”searchfield” prompt=”select”>
<option selected>select</option>
<option value=”phonenumber” >Phonenumber</option>
<option value=”name” >Name</option>
<option value=”city” >City</option>
</select>
</td>
<td>
<%= text_field_tag ’searchkey’ %>
<%= submit_tag “Search” %>
</tr>
</table>
</div>
<%= end_form_tag %>
Controller:
def search_number
if params[:searchfield]
session[:field]= params[:searchfield]
end
field = session[:field]
if params[:searchkey]
session[:query] = params[:searchkey]
end
query= session[:query]
@total, @phones = User.full_text_search(field,query, :page => (params[:page]||1))
@pages = pages_for(@total)
if @phones.length > 0
render :action=>’search_number’
else
render :text=>’No Result’
end
end
