Tuesday, May 26, 2009

Automated Functional Testing

Automated Functional Testing

By Bhrigu Malhotra

First of all let me make you all aware that I’m a developer and what you are going to read further is a developer’s account, so it may sound to you like a layman tester. But what I’m going to share is something which has been very helpful to me to ‘functionally’ test the web application our team has been building and I thought this may help you as well. So even if you are a tester, try to think the way developer’s think for some time, I’m sure this would be useful to you too.

Before I go ahead, I think we all understand that Functional Testing is testing the functionality of our application which means you’d probably be going through a login using some credentials, clicking some links, verifying some outputs - in simplest terms. Now just give it a thought that if you can automate these i.e. invest some time for once and then while you are sipping a cup of coffee, someone is testing what you coded. Change your code 10 times and run your test 10 times to ensure nothing breaks, so easy. Not just this if you have continuous integration server setup which runs your tests, you’d come to know immediately if and when someone else broke your code. Believe me ones who have used it, feel it is fantastic.

There are a variety of tools available for this over internet each with pros/cons but I’m going to share some info here about one which I liked very much and have been using for a while now. I’d also share why I preferred it over others.

Ok, no longer prolonging the suspense the tool I’m talking about is called Canoo WebTest (webtest.canoo.com) which is a free Open Source tool for automated testing of web applications in a very effective way. The primary reason why I liked it is that it is FAST; very fast … most of the test cases that I’ve written are executed in less than a minute and that too over remote applications deployed on servers on the other side of globe. Second reason for liking it so much is the ease of writing; very quickly you can build up your tests. Though they have released a WebTest recorder plug-in which when installed in Mozilla Firefox can record the script for you, but believe me the more you start writing there test cases, the less reliant you will become on the recorder. Third thing is these tests do not use a browser so that completely eliminated browser-specific issues which some tools are plagued with.

Now some things about WebTest which some people don’t like is you actually do not see the tests being executed i.e. loading of a browser window, automatic clicking on buttons and errors on the screen (if any). But that I feel that it is so by design …. Doing all this takes time and then browser issues too creep in, so I’m happy like this way only. I agree they can improve on reporting of errors but again the objective of this tool is to test and just to test, if you want to report issues manual intervention is needed.

At last I’ll just say go give it a try, I’m sure once past initial hiccups, you’ll start liking it the way I am.


http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au

How to Access Command prompt from QTP

How to Access Command prompt from QTP


By Parul Wahi

We can even access Microsoft Windows command prompt also known as MS-DOS from QTP interface.cmd.exe is a 32-bit command prompt used in Windows NT, 2000 and XP and offers disk and file maintenance functions as well as network functions. It can be found under System32 folder.

To launch cmd.exe from QTP write :

SystemUtil.Run “cmd.exe”, “”, “c:\WINDOWS\system32”,”open”

Once DOS window launches, this window can be leant and added to object repository

To write on command prompt window use the following code:

Window( “object class:=ConsoleWindowClass”).Type “Ping crestechsoftware.com”

Window( “object class:=ConsoleWindowClass”).Type micReturn

Using WshShell object

The WshShell object gives your scripts the ability to work with Windows shell .Your scripts can use the WshShell object to perform a number of system administration tasks, including running programs, reading from and writing to the registry, and creating shortcuts.

Following are the list of few methods used with wcript object:

1)The Environment property helps in getting environment variables

2)The Exec method returns a WshScriptExec object, which provides status and error information about a script run with Exec along with access to the StdIn, StdOut, and StdErr channels. The Exec method allows the execution of command line applications only.

3)Pop Up Method Displays text in a pop-up message box.

4)RegRead Method helps in reading from registry

Example

The following example demonstrates the basics of the Exec method.

Dim WshShell, oExec

Set WshShell = CreateObject(”WScript.Shell”)

Set oExec = WshShell.Exec(”calc”)

Do While oExec.Status = 0

WScript.Sleep 100

Loop

WScript.Echo oExec.Status


http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au

How to Execute QTP script from Command Prompt using Automation Object Model

How to Execute QTP script from Command Prompt using Automation Object Model

By Parul Wahi

In order to run QTP scripts on schedule, we can run them directly from command line.

In order to do so we can make use of QTP Automation Object Model which can help us in automating QuickTest operations. Using the objects, methods, and properties exposed by the QuickTest automation object model, we can write scripts that configure QuickTest options and run tests instead of performing these operations manually using the QuickTest interface.

In the following code we are trying to execute a QTP script called “Google_search” from command line. Let’s create a script in QTP and save it as Google_search.Write the following code in a vbs (VB Script) file as save it as demo.vbs:

Dim qtApp ‘ Declare the Application object variable

Dim qtTest ‘ Declare a Test object variable

Dim qtResultsOpt ‘Declare a Run Results Options object variable

Set qtApp = CreateObject(”QuickTest.Application”) ‘ Create the Application object

qtApp.Launch ‘ Start QuickTest

qtApp.Visible = True ‘ Make the QuickTest application visible

qtApp.Open “C:\Documents and Settings\pwahi\Desktop\Google search“, True ‘ Open the test in read-only mode

‘ set run settings for the test

Set qtTest = qtApp.Test

qtTest.Run’ Run the test

WScript.StdOut.Write “Status is:” & qtTest.LastRunResults.Status ‘ Check the results of the test run

qtTest.Close ‘ Close the test

Set qtTest = Nothing ‘ Release the Test object

Set qtApp = Nothing ‘ Release the Application object

Now in order to execute QTP script from command line we have to execute the above created vbs file from command prompt which will in turn launch QTP, open the script, run it and will display the result in command prompt only. Open command prompt and write following code:

C:\Documents and Settings\pwahi\Desktop>cscript //nologo demo.vbs

And press enter

This command will execute the demo.vbs file which in turn launch QTP, open the script Google search, execute it and will display the result in QTP result file. We can also see the results in command prompt as shown below.



http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au

Script Services

Script Services

By Renu Bala

Script Support Functions enables you to insert code into Functional Tester Script to perform variety of tasks. These tasks include:

• Calling a script from a Functional Test Script
• Inserting Log Messages into Functional Test Script
• Using timers with Functional Test Script
• Setting delays and sleep states for Functional Test Script Playback
• Inserting comments into Functional Test Script

The Script Support Functions dialog box has following tabs:

1. Call Script for Calling a script from a Functional Test Script
2. Log Entry for Inserting Log Messages into Functional Test Script
3. Timer for Using timers with Functional Test Script
4. Sleep for Setting delays and sleep states for Functional Test Script Playback
5. Comment for Inserting comments into Functional Test Script

To use script support commands Click on Insert Script Support Commands button on Recording Monitor Toolbar.

Call Script
While recording or editing a functional test script, you can insert a call to a previously recorded script. This lets you avoid repeatedly recording similar actions on the AUT by taking advantage of scripts that already exist.
CallScript inserts following code in the script at the cursor location:

callScript (“scriptname”)
Where scriptname is the name you selected in the script name field.

Log Entry
You can insert a log message into a functional test script and indicate whether it is a message, a warning or an error. During playback, RFT inserts this information into the log.
LogEntry inserts the following code into the script based on the option you selected (message, warning, error):

logInfo(“Message”)
logWarning(“Message”)
logError(“Message”)
Where Message is the text you entered

Timer
You can insert timers with different names into the same script to measure time it takes to perform a variety of separate tasks. You have to explicitly stop the timer to calculate the time taken by the set of events.
The code generated is:
timerStart(“name”)
timerStop(“name”)
Where name is the variable name you want to use for the timer.

Sleep
You can insert sleep command into Functional test script to delay the script for specified time.
The code generated is:
Sleep(seconds)
Where seconds is the time entered in seconds fields.


http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au

Performance Testing: Handling maximum database user connection

Performance Testing: Handling maximum database user connection

By Pankaj Goel

While working on performance testing assignments, many a times, I came across situation where following error was reported while applying load on the system
“The Maximum Connection Limit Has Been Reached”
On further analysis, I found that the error was being returned by the database (MS SQL Server in this case). Here is in this post, I have tried to detail what all to do when you get this error
So for MS SQL Server (2000 or 2005), if you have identified that the number of user connections is high, you can control the number of user connections by doing one of the following:
• Enable Microsoft SQL Server to automatically add user connections as needed. Do this through the Microsoft SQL Server SQL Server Properties window by setting the user connections configuration option to 0. If you specify a value other than 0, Microsoft SQL Server allocates memory for those connections at startup, which burns up portions of the memory pool.

• Specify a maximum number of user connections. Set this amount to the expected maximum number of concurrent users. Microsoft SQL Server rejects new login requests after reaching the maximum number of user connections when this value is set. After changing the maximum number of user connections, you must restart Microsoft SQL Server.

To re-configure the maximum number of user connection, In SQL Server 2000, you can use the sp_configure stored procedure. When you install SQL Server, the default value for user connections is 0 (32767 concurrent connections).
a) Start SQL server from command prompt
sqlservr.exe -c -f
b) Issue the following command
sp_configure ‘user connections’, 0
go
reconfigure with override
This code sets user connections back to the default setting.
c) Restart SQL server normally

For further details about the optimum SQL server settings, resources @ the following link contain some good information
http://support.microsoft.com/kb/319942/EN-US/
http://support.microsoft.com/kb/224587/



http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au

Descriptive Programming in QTP

Descriptive Programming in QTP

By Parul Wahi

What is Descriptive Programming?

QTP can perform some action on objects at run time only when it is able to uniquely identify the object. In order to identify the object at run time (play back), QTP learns some physical properties of the object at the time of recording and stores them in object Repository (OR). When QTP runs the script, it compares these properties and values to the actual objects appearing in the application, and performs the action on the object if it finds it.

Thus, it is not possible for QTP to perform action on objects during run time if the objects are not there in OR. But descriptive programming provides a way to perform action on objects which are not in Object repository. We can instruct QTP to perform methods on the objects that are not there in object repository with the help of programmatic description or descriptive programming.

When and Why to use Descriptive programming?

When using Descriptive Programming (DP), we’re bypassing the native object repository (OR) mechanism which may have many advantages. Let’s examine the situations in which the OR’s advantages are outweighed by the DP.

Suppose we are testing the site that displays the list of users whose details matches with the search criteria that is entered in search text field. With the names, the application also displays checkboxes against each name. Now, we want to test the scenario where application sends mail to all the users whose names are displayed in the list. But we are not sure how many check boxes will be displayed on the page as the search criteria can differ . In this situation, you can use a programmatic description to instruct QuickTest to perform a Set “ON” method for all objects that fit the description: HTML TAG = input, TYPE = check box

The other usage of DP can be as follows:

1) Programmatic descriptions can be used to perform the same operation on several objects with certain identical properties, or to perform an operation on an object whose properties match a description that is determined dynamically during the run session.

2) One place where DP can be of significant importance is when you are creating functions in an external file. You can use these function in various actions directly, eliminating the need of adding object(s) in object repository for each action [If you are using local object repository]
3) The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout ”.

4) When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object.

5) When you don’t want to use object repository at all. Consider the following scenario which would help understand why not Object repository

Scenario 1: Suppose we have a web application that has not been developed yet.Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing

Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page.

6) When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.

How to use Descriptive programming?

There are two ways in which descriptive programming can be used
• Static. You list the set of properties and values that describe the object directly in a VBScript statement.
• Dynamic. You add a collection of properties and values to a Description object, and then enter the Description object name in the statement.

Static method
In Static method , we can write down the physical description of the object in the script itself rather than using it’s logical name. The syntax for this is :
TestObject(”PropertyName1:=PropertyValue1?, “PropertyName2:= PropertyValue2?)
Where, TestObject is . The test object class. Eg WinButton , WebEdit , WinCheckBox etc
PropertyName:=PropertyValue. The test object property and the value identification string. Each property:=value pair should be separated by commas and quotation marks
Eg.1 DP code for login into the FLIGHT RESERVATION (sample Application of QTP) is :
Dialog(”text:=Login”).WinEdit(”nativeclass:=Edit”,”attachedtext:=Agent Name:”). Set “fgfdgfdgf”
Dialog(”text:=Login”).WinEdit(”nativeclass:=Edit”,”attachedtext:=Password:”).SetSecure “48a1881a08961df276749334f4511d5a7d35e922?
Dialog(”text:=Login”).WinButton(”text:=OK”,”nativeclass:=Button”).Click
Window(”title:=Flight Reservation”).Close
Dynamic Method

QTP provides another method which provides more efficiency, power and flexibility known as Dynamic method.

Under Dynamic method you can use the Description object to return a Properties collection object containing a set of Property objects. A Property object consists of a property name and value. You can then specify the returned Properties collection in place of an object name in a statement.

Eg2. The first example mentioned above for Flight Reservation application can be written as follows using Dynamic method:

Set desc=description.Create()
desc(”text”).value=”Login”
desc(”Class Name”).value=”Dialog”

Set agent=description.Create()
agent(”nativeclass”).value=”Edit”
agent(”attachedtext”).value=”Agent Name:”

Set password=description.Create()
password(”nativeclass”).value=”Edit”
password(”attachedtext”).value=”Password:”

Set button=description.Create()
button(”nativeclass”).value=”Button”
button(”text”).value=”OK”

Dialog(desc).WinEdit(agent). Set “fgfdgfdgf”
Dialog(desc).WinEdit(password).SetSecure “48a1881a08961df276749334f4511d5a7d35e922?
Dialog(desc).WinButton(button).Click
Window(”title:=Flight Reservation”).Close


http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au

SOA Testing Simplified (Series-IV)

SOA Testing Simplified (Series-IV)


By Pallavi Sharma

In the last series we saw what are the various challenges which a tool should overcome to test a SOA based application. We saw a list of commercial and open source tools which can assist us in testing our web services.

From this series we will take each tool one by one and understand what all it has to offer us. The first solution to web service testing we will consider is the one provided by Rational. Rational offers the following solutions:

a. Rational Tester for SOA Quality
b. Rational Performance Tester Extension for SOA Quality.

Following are the list of features which they offer:

• Both built on Rational Performance Tester technology
• Support for Web Services standards UDDI, WSDL, SOAP, HTTP, HTTPS, WS-Security
• Integrated with Rational Test Management tools (Test Manager with ClearQuest)
• Monitoring tools (Tivoli) can be easily integrated with it.



http://www.qacampus.com
http://www.crestech.in
http://www.crestechsoftware.com.au