Monday, August 24, 2009

Selenium - Handling dialog box in MAC

What's the problem ?
How to Handle Dialog box in windows ?
How to handle Dialog box in MAC ?
Download the script ?
How to invoke the script/application. ?
Download the executable (app)

Selenium is a great tool to automate the web application. It supports you to test on multiple browser and on multiple Operating Systems. But it has few problems too. One if it's problem is it becomes blind when it comes to identify any of the dialog boxes. This is because dialog box are native components and selenium is designed to identify the web elements only (design bug, ahh just kidding)

How to Handle Dialog box in windows ?
You are bit lucky if you are using Windows Platform, coz then you can use Autoit to handle these dialog boxes. check this out the below link for
http://qtp-help.blogspot.com/2009/07/selenium-handle-dialogs.html

How to Handle Dialog box in MAC ??
But what if you are testing on mac? obviously you can't use AutoIt. But that doesn't mean you can't handle the dialog box on the mac. Mac provides better facility than windows in this case. You don't even need to download or install new software for this. Mac has the AppleScript which you can use to handle to dialog boxes.

Don't worry if you don't have much knowledge about AppleSctript, It's just like other scripting languages ( actually it's not, it will look bit weird if you have used Shell script or JavaScript before).

Before I found out that the applescript can solve the problem, and write down this piece of code I wasn't aware of the AppleScript, neither I have worked on the MAC in my life. So to write down this little piece of code took my whole 3 hours. But I am happy as it's working.

Following is the script to handle the Authentication dialog box of Firefox in mac.


(*
Created By: Gaurang Shah 
   gaurangnshah@gmail.com 
   
Purpose: To handle the Athentication dialog box in Firefox.
Usage: Filename UserName Password
*)

delay 10

on run argv
 tell application "Firefox"
  activate
 end tell
 
 
 tell application "System Events"
  if UI elements enabled then
   tell process "Firefox"
    set frontmost to true
   end tell
   
   if length of argv < 2 then
    display dialog "Usage: FileName UserName Password"
    return
   end if
   
   keystroke item 1 of argv
   keystroke tab
   keystroke item 2 of argv
   keystroke return
   
   
  else
   tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.universalaccess"
    display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
   end tell
  end if
 end tell
end run

Download the script

You can write down the similar script to handle other File Open and File Save Dialog boxes.

How to call the script
It's quite to easy to invoke the script.
Just open the script in Script Editor and save the script as application. In the Java File write down the following line just before the line that shows dialog box
dialog =  new String[]{ "Handle_Authentication_Dialog_FF.app","UserName","Password" };
//First String in the application name. Must be in your project folder. 
// Second is UserName to log in 
// Third is Password.
Runtime.getRuntime().exec(Dialog);

The other way is that you can open the Shell Prompt and pass the application name and it's arguments as follows. I am not sure this will work or not.
dialog =  new String[]{ "Shell prompt","Handle_Authentication_Dialog_FF.app","UserName","Password" };
//First String in the application name. Must be in your project folder. 
// Second is UserName to log in 
// Third is Password.
Runtime.getRuntime().exec(Dialog);

Monday, August 17, 2009

Free Test Management tools

Recently moved into another project and got the chance to evaluate test management tools. The requirement was simple.
1. It must be free. (it was an internal project and so we can't spend money) better if it's open source in this case we can change or add the things.
2. Easy to use.
3. Should provide the facility to connect to mantis or Bugzilla BTS.

So I started searching on the forum and Google for the free Test Management Tools and end up with plenty of that. It's nice to have plenty of options to choose from, but not when you are running out of time. I have got only a week to do this, with too much work in the another project. So I simple gone through the features they provides, and based on that I picked some six tools to evaluate.

After deciding which tools to evaluate, I started downloading, installing and configuring them to see what they offers. After evaluating most of the tools and ran out of time I finally decided to evaluate only two tools further.

Following is my experience with tools.

From the 6 test management tools I picked, two are client-server application and other four are web based application, Which are developed in PHP and uses MySQL as database.

Client-Server
1. XStudio: It's quite a good client-server Test Management tool with XStudio as server and XAgent as client.
It provides you to write down Test Plan, Requirements, Test Suites and Test cases. It also provides the requirement coverage matrix. The installation and configuration is easy is easy.
But the problem was that it was crashing too frequently on my machine, so didn't able to evaluate in detail.

2. Salome: It's yet another client-server Test Management Tool made in JAVA and uses MYSQL as database. provides all the facilities of normal test management tool.
The only problem I face is that it's performance was sluggish on my machine, and it did hang couple of times, might be coz mine is not a server.

I drop down the whole idea of using client-server Test Management tool. Primarily because both the software I installed seemed to be unreliable. The other problem with client-server is every time you adds a user you need to install the client application on his machine. This is quite a nice thing from security point of view but we didn't want any of the installation headache.
So finally I decided to move with web based projects only.

Web Based:
Following are some of really nice web based test management tools which have been developed in the PHP and uses MYSQL as database.

2. QaTraq: This pops out as free tool in my search, but when I visited the site I became suspicious about the free and open source thing.
So I search further on site and find out that it's not free. the project was initially started as open source project, but as they didn't get any help from the community they changed it to paid one.
They still have an open source version available on sourceforge.net but the problem is that, it's about an year old. there isn't any active community to solve your bugs or to add features, So it's bit risky to use it.

The online demo of the paid version is available on request. you can check that out. But i drop the idea of using this one as we didn't want to spend a penny on the software.

4. RTH: It's known as Requirements and Testing Hub. It provides the features to create Test Plan, requirements, test cases. to store test result per release. It also has it's own BTS (bug tracking system). Provides the requirement coverage matrix too.
What I really like about the tool is it provides the facility to import and export test cases from excel file.
What I don't like about it is, It doesn't provide the facility to connect to mantis or Bugzilla BTS and it's bit complex to use.
It has a good facility for user role management but doesn't have facility to assign work to some user.

one of the nicest thing about the RTH is that it has online demo available. So to evaluate the tool you don't need to waste you time in downloading, installing and configuring it.
The online demo is available on following site
site:http://rth.liedl.at/login.php
User Name:admin
Password:password

1. Testlink: From all the tools I evaluate this is one is simplest to Install, Configure and Use.
Provides all the features, creating and storing test plan, requirements, Test sets, Test cases, Test results, Requirement coverage matix and much more.
What I really like about the tool is, It provides you to connect to mantis or Bugzilla.
It also allows you to import and export test cases, requirements and other things from Excel,XML,CSV. Which is quite a nice thing, I mean if you have already write down the requirements, and test cases in excel file, rather then doing a copy and paste simple import will solve your problems.

Testlink also provides the online demo. So you can check that out to evaluate.
Site: http://testlink.org/demo/login.php?note=expired

3. qaManager: Actually didn't get the time to evaluate this one. But it seems promising too.

After evaluating all the tools we finally decided to use TestLink, as it is simple to use and provides import export from excel file and also connects to mantis or Bugzilla.

The only problem we have is (or we might have), the stable version is 1.7.3 while we have choose to use 1.8.3 as 1.7.3 doesn't allow to directly import things from excel file.