Thursday, March 25, 2010

Quick Test Professional Operations

1) Adding object repositories at runtime:

Suppose I have a shared object repository (myresource1.tsr) and I want to make sure that the repository is already associated with my test. If not I want to associate the repository and carry on with my execution. Then open your test file and type in the following script to check for or add object repository at run time.

 If repositoriescollection.Find ("C:\Program Files\myresource1.tsr")<0 Then

      repositoriescollection.Add  "C:\Program Files\myresource1.tsr"
    
 End If

Sunday, February 21, 2010

Microsoft Excel Operations

1) Create an Excel File and write into a cell :

Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.add
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.name = "Subrat"
objSheet.Cells(1,1) = "Column A"
objExcel.ActiveWorkbook.SaveAs "E:\TestXL.xls"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit

2) Overwrite an Existing Excel File by suppressing the alerts :


Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.add
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.name = "Subrat"
objSheet.Cells(1,1) = "Column B"
objExcel.Visible=True
objExcel.DisplayAlerts=False
objExcel.ActiveWorkbook.SaveAs "E:\TestXL.xls"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit

3) Open an Existing Excel File and write values to it in the following format :



Set objExcel = CreateObject("Excel.Application")
objExcel.Visible=True
objExcel.DisplayAlerts=False
Set objWorkBook=objExcel.Workbooks.open( "E:\TestXL.xls")
Set objSheet= objWorkBook.Worksheets(1)
objSheet.Cells(1,1).value="ColumnA"
objSheet.Cells(1,2).value="ColumnB"
objSheet.Cells(1,3).value="ColumnC" 

For i= 0 to 2
     For j= 0 to 2
         objSheet.Cells(i+2,j+1).value=j+1
     Next
Next

objWorkBook.SaveAs "E:\TestXL.xls"
objWorkBook.Close
objExcel.Quit





VB Script And File Operations

This page contains the link to all the the file operations using VB Script and QTP

1) Microsoft Word File Operations

2) Microsoft Excel File Operations

3) PDF File Operations

4) Microsoft Outlook Operations

5) Text File Operations

Microsoft Word Operations

1 ) Check the existence of  a Microsoft Word file and if the file is present delete it and add a new file....

' Declare the variables

Dim objFso,objMyFile,strFileName,objWord,objDoc,objSelection

  strFileName="Subrat.doc"
 
  'Create an object of class FileSystemObject
   
    Set objFso = CreateObject("Scripting.FileSystemObject")
 
  'Check if the folder structure exists, if not, create it

    Dim sFolder : sFolder = "c:\MyFile"
    If (objFso.FolderExists(sFolder)) Then
        'do nothing
   Else
        Set objFolder= objFso.CreateFolder(sFolder)
   End If
  
    Dim FileName : FileName = "c:\MyFile\"&strFileName
   
    If objFso.FileExists(FileName) Then
            Set objMyFile = objFso.GetFile(FileName)
            On error resume next
                objMyFile.Delete
                If err.number <> 0 Then
                    LogWarn "Could not delete the file : >>> ", "c:\MyFile\"&strFileName
                    err.clear
                End If
    End If
       
    'Add a ms word document
 
  Set objWord = CreateObject("Word.Application")
  Set objDoc = objWord.documents.add
  Set objSelection = objWord.selection
  objSelection.typetext "My new document"
  objDoc.saveas(FileName)
  objWord.Quit
 
  'Clean up
 
  set objWord = nothing
  Set objDoc= nothing
  Set objSelection = nothing
  Set objFso= nothing
  Set objMyFile= nothing

Tuesday, December 29, 2009

Closing Multiple Browsers at a time

The following script will close multiple browsers that are currently open:

Method 1:

Set BrowserObject=Description.Create()

BrowserObject("micclass").value="Browser"

Set BrowserChildObjects=Desktop.ChildObjects(BrowserObject)

For i=0 to BrowserChildObjects.count-1

BrowserChildObjects(i).close

Next

Method 2: By closing the running process

SystemUtil.CloseProcessByName "iexplore.exe"

Method 3: If we want to exclude a particular browser, we have to make modification to the 1st script

Set BrowserObject=Description.Create()
BrowserObject("micclass").value="Browser"

Set PageObject=Description.Create()
PageObject("micclass").value="Page"

Set BrowserChildObjects=Desktop.ChildObjects(BrowserObject)
For i=0 to BrowserChildObjects.count-1

    Set PageChildObjects=BrowserChildObjects(i).ChildObjects(PageObject)(0)
    If Instr(PageChildObjects.GetROProperty("title"),"")=0 Then 'Provide the appropriate title of the page within the double quotes

        BrowserChildObjects(i).close

    End If

Next

Monday, December 28, 2009

HP Quick Test Professional

By far one of the best commercial tool available in the market for Software Test Automation.

It goes beyond GUI (Graphical User Interface) Level Testing and caters not only to web applications but also    to Web services, Database Testing, Extensible Markup Language (XML's) , Windows Applications., etc....

In this section we will delve deep into the features of QTP as a tool and how to maximize its advantages.

Keep checking out this space for more.... :)


Why Automation???

"30k test cases and the time limit to test is just in an excess of a week's time"
Is it possible???
May be or may not..... no word to the client... a tentative "Yes"... we will try to do it.... but...
Ifs and buts galore... and rightly so... effort is huge and resources at disposal the least.... and we end up loosing Client's confidence....

Well its just one of the simple example to depict "Test Automation" is here to stay... it is now a very integral part of our Software Testing Life Cycle and its a parallel Software Development Effort in the hugely process driven Software Testing Life Cycle.

Reasons galore and I think I need not explain much to my readers as to why we go back again to some kind of development process while Testing a Developed Software/Application.

So lets get started with the process of Test Automation by digging in deep into the tools that we have at our disposal or let's do a research on the development acumen we have within ourselves to automate a manual process.

Having said that, I would like to stress on the fact that "Software Testing" can never be all Automation dependent... Automation is an extension to Software Testing process in a Technical way... It can never replace a human effort in this stream.... So I welcome anyone who is interested to improve the process to my postings...which may help you in many ways.