Thursday, June 4, 2009

Dynamically Creating QTP Test Batch File/Test Suit

Let us consider that our test folders are ready...
now run this code over the main folder that includes all test folders...
It will create .mtb batch file for test...

you can even open the .mtb file with notepad & adjust the sequence of test..

Function TestsToTestSuit(TestDirPath)
filename=TestDirPath & "\ProjectTestSuit.mtb"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(TestDirPath)
set colSubfolders = objFolder.Subfolders
Dim myarray()
dim i
i=1
If fso.fileexists(filename) Then
fso.deletefile(filename)
End If
Set file= fso.CreateTextFile(filename, ForAppending, True)
file.Writeline("[Files]")
file.Writeline("NumberOfFiles=" & objFolder.Subfolders.count)

For Each objSubfolder in colSubfolders
ReDim preserve myarray(i)
If (objSubfolder.Name<>"Screenshots") Then
myarray(i)=objSubfolder.Name
file.Writeline("File" & i & "=" & TestDirPath & "\" & objSubfolder.Name & ";1 ")
i=i+1
else
i=i+1
End If
Next
file.close
DirectoryNameToArray=myarray
End Function


i have excluded "screenshots" folder from SVN Test script folder

Wednesday, June 3, 2009

QTP framework for companies, automating the automation

Hi,

I am working as a QA Lead in chandigarh.. I joined QA field 2 years back.
I have 4.5 years of software developement experience in microsoft tech.
I GOT A TEAM OF 4 QA MEMBERS.

6 month ago... my company management asked me to have some sort of automation testing. Initially I took Selenium as it is a open source & easily available.
I created a selenium smoke testing script that runs over the build....

Then I found It is very tedious to work with it.
FINALLY I CHOOSE QTP TRIAL...EXCELLENT ONE...


I GOOGLED ABOUT MAKING A FRAMEWORK.. I PUT MY WHOLE DAY ... AND ALSO AKSED MY COLLEUAGE (MR. SAHIB) TO DO SO...
FINALLY AT THE END OF DAY...ALL WAS IN VAIN..

WHILE TRAVELLING TO MY HOME.. I AGAIN THOUGHT ABOUT IT.. WHAT TO DO..HOW TO DO.... THEN GOT A EXCELLENT IDEA..
EUREKA....

NEXT DAY I TOOK IT INTO HAND...WE STARTED creating a complete QTP testing framework without using any OBJECT REPOSITORY.

Then I decided to have such a script that will move over all the pages of website..
It uses vbscript FULLY. IT IS 90% COMPLETE NOW..

Here is how it works....

Using inputbox() of vbscript...
It asks for main folder name to be created for project...
It asks for login textbox name...
It asks for password textbox name...
It asks for login & password...
It asks for name of login button...
It tells total no. of links on page e.g. 96...
It asks for the link number to start with...
It collects window Page Title & URL in a text file (to check naming conventions)
It finds missing attributes like maxlength,alt,title, tabindex... etc..

Creates folders for each QTP test to be created
It copies a default test settings from a folder to each test automatically..
then creates the tests scripts automatically for all the pages...
grabs screen shots in a directory...
creates data table global sheet & puts column names automatically (does not matter number of controls)....
It fetches values from data table & does entry in all controls in the pages automatically...

fires input validations,mandatory and other,captures screenshots of crashes, page not found, gathers URL

checks spellings
checks W3C XHTML validations conformance
checks W3C CSS conformance
checks W3C WCAG conformance

other so many things.....

finally creates test suite .mtb automatically...


THATS IT...
NOW OUR LIFE IS SAVED & EASY.
DO YOU WANT TO KNOW WHAT WE DO NOWA DAYS?
WE JUST CLICK RUN BUTTON OF QTP AND GET ALL SCRIPTS IN SVN FOLDER AUTOMATICALLY.....
:-)