Monday, December 7, 2009

Watir tips

Hi Guys,

Waitr is a ruby gem used in testing. It has many uses, mostly it is used to control the web browser(all html dom elements as objects).

installation command:-
gem install waitr

Some sample use of watir

1. Starting a new Web browser
require 'watir'
ie = Watir::Browser.new
ie.goto("http://www.google.com")

2. Starting a firefox browser
require 'watir'
Watir::Browser.default = "firefox"
ff = Watir::Browser.start("http://www.google.com")

3.Setting a text field with some value

ie.text_field(:name, "username").set "Vaddi"

4. Setting value of select list

ie.select_list( :name , "category").select("Comedy")

For all the DOM elements, it has objects(for text box - 'text_field', for drop down - 'select_list')

thanks,

Friday, December 4, 2009

for loop - js

In javascript, to read the array index and their appropriate value.

Use the following way,

var a = Array.new(); declare new array with name 'a'
a = [1,2,3,4,5]; assign some values to array
var indexes = function show(value, indx){
alert(indx);
alert(value);
}
a.forEach(indexes);
'forEach' method is used to collect the values from the array.

By using the method 'forEach', we can collect each element from array.

Try this..