Showing posts with label Watir vs. Selenium. Show all posts
Showing posts with label Watir vs. Selenium. Show all posts

Watir Recorder 2

This is how watir recorder performed for the following elements. The result is not very satisfying, but i still prefer to use the tool. It saves a lot of your time. At least it can recognize the most essential html elements.


HTML Field Recognized? Comment
text inputYes
buttonYes
linksYes
checkboxYes
dropdown listYes
radio button Yes
frameNoUnable to recognize objects inside
iframeNoUnable to recognize opjects inside
optgroupNo
optionNo
textareaNo

Watir Recorder

I am required to automate a portion of a .NET application to cut down the time spent in smoke testing. I have used Selenium RC successfully on other projects that run on both Internet Explorer and Firefox. I used Selenium IDE for firefox to record user actions and Selenium RC under eclipse to tune my script and add logic, switching and DB Access blocks. And JUnit of course to create test cases.

There's a little problem: the application is a .Net back office application that is always run on Internet Explorer by internal clients. Because of that, the developer haven't ever paid attention to browser compatibility. And as a result, the application runs terribly on Firefox. And it's not possible to use Selenium IDE to record actions and then run the scripts on IE.

Theoritically, it's possible to code all your scripts by hands using Selenium and run them on IE with Selenium RC, but who has time to do that?

I've heard about Watir before, but never used it. Now i am experimenting with it and i like what i see. Watir Recorder will seamlessly save your time in recording user actions. Here's how a recorded ruby script will look like using Watir Recorder (click to enlarge):


Or you may prefer the text version:

require 'watir'
include Watir
require 'test/unit'
class TC_recorded < Test::Unit::TestCase
def test_recorded
ie = IE.new
ie.goto('http://www.google.com/webhp?sourceid=navclient&ie=UTF-8')
ie.link(:url, 'http://www.google.com/advanced_search?hl=en').click
ie.text_field(:name, 'as_q').set('testsquad test automation blog')
ie.select_list(:name, 'num').select_value('10')
ie.select_list(:name, 'num').select_value('20')
ie.select_list(:name, 'lr').select_value('lang_en')
ie.button(:value, 'Advanced Search').click
end
end


Up from this point you can copy your base script to a ruby (*.rb) file and add whatever logic, switching and DB access blocks to extend and parametrize your test. Today, Watir Recorder has been able to recognize text boxes, buttons, links and combo boxes for non .Net applications. As i said, i am still experimenting and i will post more results in the coming days.

Please share your experience! :)