Monday, December 13, 2010

Test Run Setting Preference in Quality Centre

• User can run the test scripts that are stored in QC via QTP

• QC clients installed in on your computer or via QC clients

Note:-

• User can’t run the test scripts from QC if QTP machine is logged and logoff

• QTP runs always hidden mode for improve the performance(tooltip will populate the information ,you can change the setting in Remote Agent

Enable the setting in QTP

• Select Tools->Option

• Click Run Note Tab

• Select “Allow other HP Products to run tests and components

Understand the setting in Remote Agent

• Remote Agent setting for support for test execution based on the application, QTP Speed and other process

Level

• Determine the QC and QTP log

None – No log is generated

Low – QC and QTP communication Errors

Medium – QC and QTP communication errors and information’s on major operation

High – Include all available information

Log folder

• The folder path for storing the log file

Reset testing tool:-

• Tool provide the option to reset the QTP tools and QC for after the no runs has completed

Save the open, modified test before the test run

• Remote agent can save any unsaved related to QTP Tests

Save the open, new test before the test run

• Remote invoke all tests and save the location Quick Test installation folder\Tests\Quality Center

Open a new test after the test run

• Remote agent has completed the test set execution after that invoke the new test in QTP

Run Quick Test in hidden Mode

• Default QTP tests run the hidden mode for improve the performance, user can customize the using “Remote Setting”

Reset testing tool

• Operation - QTP configure the operation like open and run (Default 2700)

• Queries – based on the remote application perform to confirm the application is responses

Thursday, December 9, 2010

Opening Tests from the Recent Files List (File Menu)

  • You can open Quality centre files from the recent file list in the File Menu
  • If you select a test located in Quality centre, but currently QC is not connected, the below window will be populated in the screen
  • 
    Add caption
    
  • Provide the require information like User Name and Password and Server name and Project name default displayed in the application

Monday, December 6, 2010

Saving the test from Quality Centre

• when Quick test connected,you can create/modify the tests in quick test and save them directly to quality centre


• File -> Save click button, Save dialog window open

• Click ‘Quality Centre Test Plan’ then select the specific location and click save button (Note:- check the check box - Screen files are uploaded into QC Else No

Integrate the QC with QTP

• QCUtil is an object to access the full functionality of the quality centre OTA(Open Test Architecture)


• You can store or retire the files and scripts from quality centre

Dim TDConnection


Set TDConnection = CreateObject("TDApiOle80.TDConnection")

Disconnect Quick Test from Quality Centre

• User can disconnect the quality centre connection from QTP like File -> Quality centre connection or toolbar button 
• While disconnect the QC, if any QC testscripts, vbsfiles,OR will automatically disconnect from QTP
 
Step3 Logout from the project or change the project

Step2 Change User or logon to new user

Step1 Disconnect form the server

After that, close the QC Connection window

 

Sunday, December 5, 2010

Function to open the data sheet

Public Function OpenDataTable(strFileName,strSheetName)

CurPath=environment("TestDir")

pathArr=split(CurPath,"\") CurDrive=pathArr(0) pathFile="\nxc Automation\Data Table\"

dataTablePath=CurDrive + pathFile strFilePath=dataTablePath+ strFileName

DataTable.ImportSheet strFilePath,strSheetName,"Global"

End Function

Check Web Button Visiable Status and click

Public Function WebButtonClick(oBjName)

Webbutton = oBjName.ToString

If oBjName.Exist(0) Then

If oBjName.Object.Isdisabled Then

WebButtonvisibleClick = False

ExitTestIteration

Else

oBjName.click

WebButtonvisibleClick = True

End if

Else

WebButtonvisibleClick = False

ExitTestIteration

End If

End Function

Create Excel,Add Sheet,Rename the Sheet

Call CreateEventIdXls()
Public Function CreateEventIdXls()

Set fs = createObject("Scripting.FilesystemObject")

Environment.Value("FolderPath") = "C:\Documents and Settings\" & Environment.Value("UserName") & "\Desktop\EventId.xls"

If fs.FileExists(Environment.Value("FolderPath")) = False Then

Set ExcelObj = CreateObject("Excel.Application")

ExcelObj.Visible = False

Set ExcelWB = ExcelObj.Workbooks

ExcelWB.Add

'ExcelWB(1).SaveAs Environment.Value("FolderPath") '& "\" &Environment.Value("TestName")

Set ExcelWS = ExcelWB(1).Worksheets

'ExcelWS(1).Activate

'ExcelWS(2).Activate

'ExcelWS(3).Activate

ExcelWS.add

ExcelWS(4).Activate

ExcelWS.add

ExcelWS(5).Activate

ExcelWS.add

ExcelWS(6).Activate

ExcelWS(1).name = "DAY1"

ExcelWS(2).name = "DAY2"

ExcelWS(3).name = "DAY3"

ExcelWS(4).name = "DAY4"

ExcelWS(5).name = "DAY5"

ExcelWS(6).name = "DAY6"

ExcelObj.DisplayAlerts = False

ExcelWB(1).SaveAs Environment.Value("FolderPath") '& "\" &Environment.Value("TestName")


ExcelWS(1).Cells(1, 1).Value = "oUTEventType"


ExcelWS(1).Columns("A:B").AutoFit

ExcelWS(1).Range("A1:B1").Font.Bold = True


ExcelWS(2).Cells(1,1).value ="oUTEventType"

ExcelWS(2).Cells(1,2).value ="oUTEventToBeVerified"

ExcelWS(2).Columns("A:B").AutoFit

ExcelWS(2).Range("A1:B1").Font.Bold = True



ExcelWS(3).Cells(1,1).value ="oUTEventType"

ExcelWS(3).Cells(1,2).value ="oUTEventToBeVerified"

ExcelWS(3).Columns("A:B").AutoFit

ExcelWS(3).Range("A1:B1").Font.Bold = True

ExcelWS(4).Cells(1, 1).Value = "oUTEventType"

ExcelWS(4).Cells(1, 2).Value = "oUTEventToBeVerified"

ExcelWS(4).Columns("A:B").AutoFit

ExcelWS(4).Range("A1:B1").Font.Bold = True
ExcelWB(1).Save

ExcelObj.Quit

Set ExcelWB = Nothing

Set ExcelWS = Nothing

Set ExcelObj = Nothing

End if

End Function

Create Excel Sheet,Add New Sheet,Rename the Sheet Name

'Call AddSheet()
Function AddSheet ()

Environment.Value("FolderPath") = "C:\Documents and Settings\" & Environment.Value("UserName") & "\Desktop\EventIdNew2.xls"

Dim ExcelObj

Set ExcelObj = CreateObject("Excel.Application")

FilePath= Environment.Value("FolderPath")

'Disable alerts

ExcelObj.DisplayAlerts = False

Set ExcelWB =ExcelObj.Workbooks.Add

'Add a workbook to the Excel App

For i=1 to 4

ExcelWB.WorkSheets.Add

Next

'Save the file

ExcelObj.ActiveWorkbook.saveas FilePath



'Close Excel

ExcelObj.quit



'Relese the Object

Set ExcelWB = Nothing

Set ExcelObj = Nothing

End Function

Monday, November 29, 2010

Find the Excel Prodcut Code, Version,UseSystem Separators, Default File Path

Dim ExcelVersion as string


ExcelVersion = CreateObject("Excel.Application").ProductCode

Msgbox ExcelVersion

Dim ExcelVersion as string

ExcelVersion = CreateObject("Excel.Application").Version

Msgbox ExcelVersion

Dim ExcelVersion as string

ExcelVersion = CreateObject("Excel.Application").UseSystemSeparators

Msgbox ExcelVersion


Dim ExcelVersion as string

ExcelVersion = CreateObject("Excel.Application").DefaultFilePath

Msgbox ExcelVersion

Raise the defect from QTP

Dim TDConnection


Set TDConnection = CreateObject("TDApiOle80.TDConnection")

TDConnection.InitConnection "http://10.128.76.242:8080/qcbin" ' URL for the DB

TDConnection.ConnectProjectEx "DomainName","ProjectName","UserName","Password "

If TDConnection.Connected Then

MsgBox("Connected to " + chr (13) + "Server " + TDConnection.ServerName + chr (13) +"Project " + TDConnection.ProjectName )

'Get the IBugFactory

Set BugFactory = TDConnection.BugFactory

'Add a new empty bug

Set Bug = BugFactory.AddItem (Nothing)

Bug.field ("BG_STATUS") = "New"

' BG_RESPONSIBLE

Bug.field ("BG_PROJECT") = "Testing"

Bug.field ("BG_SUBJECT") = "Automation Testing"

Bug.field ("BG_SUMMARY") = "Automation Testing"

Bug.field ("BG_DESCRIPTION") = "QTP create the Defect Log for Automation Testing"

' BG_DEV_COMMENTS

Bug.field ("BG_SEVERITY") = "Severity 4"

Bug.field ("BG_PRIORITY") = "Low"

Bug.field ("BG_DETECTED_BY") = "UserNAme"

Bug.field ("BG_USER_01") = "Raised"

Bug.field ("BG_USER_02") = "Cycle 0"

Bug.field ("BG_USER_06") = ""

Bug.field ("BG_USER_09") = "1375484"

Bug.field ("BG_USER_10") = "SIT"

Bug.field ("BG_USER_11") = "Automation"

Bug.field ("BG_USER_12") = "Others"

Bug.field ("BG_USER_15") = "IN"

Bug.Post

Else

MsgBox("Not Connected")

End If

Wednesday, October 6, 2010

How to Connect QC Using QTP

  • When working with automation testing scripts using Quality centre and QTP, need to established the connection
  • Make sure that QC Add-in installed into local system in ‘Quality Centre connectivity Add-in”
Quality Centre:
Quality Center is a data portal for collecting and storing data relevant into a manual testing process, Automation Scripts and business components

Invoke the QTP Application and click File-Quality Center Connection

  • Provide the Server URL, Username, and Password, Domain and Project Information and User can able to retrieve/Access the Data portal from quality Centre















Open the Scripts/function library and data files from QC:

  •         If Click Open -> Quality Centre Test Plan, it will populated all the folder structure in Quality centre














Save all the scripts/function in QC:

  • Select the Stored the file location
  • Entered File Name
  • If you require to save Active Screen files into QC
  • Finally click ‘Save’ button

Tuesday, October 5, 2010

Check and Create the Folder in Local System

Public Function CreateFolder()
   Environment.Value("OutSideViwerAutoFolderPath") = "C:\COPEPerlAutomationExecution"
   Set fs = CreateObject("Scripting.FileSystemObject")
   If fs.FolderExists(Environment.Value("OutSideViwerAutoFolderPath")) = False Then
     fs.CreateFolder (Environment.Value("OutSideViwerAutoFolderPath") )
   else
     Msgbox "Folder Exists"
   End if
  End Function

Read the Value from the Notepad

Call ReadNotepad(oBjmyfile,oBjFileLocation,Trn,oBjAmtDate)
Public Function ReadNotepad(oBjmyfile,oBjFileLocation,Trn,oBjAmtDate)
                                    Const ForReading = 1, ForWriting = 2
                                    myfile = "!!" & Space(1) & "REF" & Space(1) & oBjmyfile
                                    Set FSOj = CreateObject("Scripting.FileSystemObject")
                                    Set oFRead = FSOj.OpenTextFile(oBjFileLocation,ForReading,True)
                                    Do until oFRead.AtEndOfStream
                                    oFRd = oFRead.Readline()
                                    MyValue1 = strcomp(oFRd,myfile,0)
                                    If Myvalue1 = 0  Then
                                                Do until oFRead.AtEndOfStream
                                                mysubfileread = oFRead.Readline()
                                                            If left(mysubfileread,4) = ":20:"  Then
                                                                        values = split(mysubfileread,":")
                                                                        Trn=values(2)
                                                                        For i=0 to 5
                                                                                    Secondvalue = oFRead.ReadLine()
                                                                                    trimSecondvalue = trim(Secondvalue)
                                                                        If left(trimSecondvalue,5) = ":32A:"  Then
                                                                                    values1 = split(trimSecondvalue,":")
                                                                                    oBjAmtDate=values1(2)      
                                                                        Exit do
                                                                        End If
                                                                        elseIf left(trimSecondvalue,5) = ":32B:"  Then
                                                                                    values2 = split(trimSecondvalue,":")
                                                                                    oBjAmtDate=values2(2)      
                                                                        Exit do
                                                                        End If
                                                                        Next
                                                                        Exit do
                                                                        Exit do
                                                            End if
                                                Loop                                                                                                                            
                                    End If
                                    Loop
End Function

Find the Notepad File in Specific Folder Location

Public Function FindNotepad()
   oBjFolderLocation =  "C:\COPEPerlAutomationExecution"
   oBjFile Name = "SubfileName.txt"
   oBjFileLocationOutSideTestData = Environment.Value("OutSideViwerAutoFolderPath") & "\" & "OutSiderViewerSubfileName.txt"
 Msgbox oBjFileLocationOutSideTestData
   Set FSOj = CreateObject("Scripting.FileSystemObject")
   If (FSOj.FileExists(oBjFileLocationOutSideTestData) = True) Then
    Msgbox "Hi"
  Set oFRead = FSOj.OpenTextFile(oBjFileLocation,ForReading,True)
  Do until oFRead.AtEndOfStream
  oFRd = oFRead.Readline()
  Msgbox oFRd
  loop
  MyValue1 = strcomp(oFRd,myfile,0)
  If Myvalue1 = 0  Then
  Do until oFRead.AtEndOfStream
  mysubfileread = oFRead.Readline()
  End if
    End If
End Function

Thursday, July 1, 2010

How do we associate a library file with in the test


  • ·         The file can contain function, sub procedure, classes etc.... You can also invoke the file using the following command like….
          (Eg) : ExecuteFile "MyFunctions.vbs"


  • ·         To associate a library file with your script File->Test Settings

How can i check if a parameter exists in DataTable

On Error Resume next
Dim Myval
Myval=DataTable("ParamName",dtGlobalSheet)
            if err.number<> 0 then
                        Msgbox “Parameter doesn’t Exist”
            else
                        Msgbox “Parameter Exist”
            end if

How can i save the Data during runtime in the Data Table

  • ·         QTP doesn’t support the run time changes to the actual data sheet.
  • ·         Using Excel or Notepad save the test data while run times
Create the Object:

  • Set ExlApp = CreateObject("Excel.Application")
    Set ExlB = ExlApp.Workbooks.open("C:\vbsample.xls")

Data Table In QTP

Data Table
Global data sheet: Accessible to all the actions
Local data sheet: Accessible to the associated action only



Example:

DataTable("Column Name",dtGlobalSheet) for Global data sheet
DataTable("Column Name",dtLocalSheet) for Local data sheet

·         During the run-time user not able to enter the data in Data Table
·         The run-time data table is accessible only through test result.
·         The run-time data table can also be export  using DataTable.Export or DataTable.ExportSheet


Thursday, June 17, 2010

Shortcut key in QTP

  •  Normal Record Mode := F3
  • Analog Record Mode := Shift+alt+F3
  •  Low level Recording := Ctrl+shift+F3
  •  Stop Recording : =F4
  •  Run the Script := F5
  • comment block := Ctrl + M
  • Uncomment Block := Ctrl+Shift+M
  • Standard checkpoint := F12
  • Step Generator := F7
  • Run from Step: = Ctrl+F5
  • Step Info := F11
  • Step Out: = F10
  • Step Out: = Shift+F11
  • Run to Step := Ctrl+F10
  • Add to Watch: = Ctrl+T
  • Insert/ Remove Breakpoint: = F9
  • Enable / disable Breakpoint := Ctrl +F9
  • Clear All Breakpoints:= Ctrl+Shift+F9
  • Syntax Check := Ctrl + F7

Explain the difference between Keyword view and Expert view

Keyword view:

Keyword is a table view structure, it represent for each row for part of the action. It contain following view as below like “item, operation, value, documentation, assignment and comments “

Item
Represent hierarchical tree view of the Test object within the table. It contains following items available on
·         Test object
·         Utility object
·         Function call
·         Statement




Operation 

What operation should be performed for each test objects in the table view like..
·         Run
·         Set
·         Secure
·         Enter
·         Type
·         Select
·         Close


Value
File location, Path , Value, Inputs of the each Test objects








Documentation
It will capture the file location; Test objects inputs and each to understand the each test objects what does for the test objects in the application

Expert View:

QTP displays each step as a VBScript line or statement. In object-based steps, the VBScript statement defines the object hierarchy
Note: Test object and method names are not case sensitive
The following diagram shows how the same object hierarchy is displayed in the Expert View and in the Keyword View


Wednesday, June 16, 2010

Descriptive Programming in QTP

Object Repository:
Ø  OR is a place to stores QTP learned objects
Ø  QTP uses default Object Identification properties: mandatory and assistive to learn objects into OR
Script play back using OR
-          QTP find the Objects in OR using Logical name and Object hierarchy
-          QTP retrieve the test object properties from OR
-          QTP search the application for the object with the same object in OR and perform the user action
Descriptive Programming:
v  Learn the object Properties and physical description of the objects and used into Script level
v  Descriptive properties is store Script level

Script play back using Descriptive programming
-          QTP search the AUT for the Object using Descriptive properties and performs user action
How to use the Descriptive programming
They are two ways in which descriptive programming can be used as below

1)    By creating properties for collection of Objects or Child Objects
    We can use description object to get all the objects on the page that matches that specific description. Suppose we have to check all the checkboxes present on a web page. So we will first create an object description for a checkbox and then get all the checkboxes from the page

Dim obj_ChkDesc
Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”
Dim allCheckboxes, singleCheckBox
Set allCheckboxes = Browse(“Browser”).Page(“Page”).ChildObjects(obj_ChkDesc)
For each singleCheckBox in allCheckboxes
             singleCheckBox.Set “ON”
Next

2)    By creating properties for Single Objects
        When going for single or specific point within a test object hierarchy, you must create descriptive properties from starting onwards
For Example,
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "vinodh"
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Type  micTab
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4c18d6c06f2d8fe29ad434c54106936bc9199553"
Dialog("text:=Login").WinButton("regexpwndtitle:=OK").Click
Window("text:=Flight Reservation").Close
Note: If initially of the code used OR objects after that, if used descriptive properties, QTP doesn’t recognize  the objects
For example
Dialog("text:=Login").WinButton("OK").Click
Error:

QTP support following applications for Automation

Default Add-ins
v  ActiveX
v  Visual basic
v  Web
Other Add-Ins
v  Siebel
v  Java
v  SAP
v  Oracle
v  Delphi
v  .Net 

Names of the Products and Vendor for Automation tools

Tool Name
Company Name
Latest Version
HP
10
IBM Rational
8.1.0.3
IBM Rational
2001
OpenSource Tool
1.0.6
Micro Focus
2009
AutomatedQA
7.52
Micro Focus
6.3
WATIR
Open Source tool
1.6.5

The benefits of Effective Test Automation

1) Cost Effective
2) Time is saved
3) Reusable the automation scripts
4) Human resources is reduce
5) Support the Development process

Object Spy in QTP

Object spy pointing mechanism for view the supported properties and methods of spy objects. Click on the “Hand symbol” button and select the window or object , it will display the Properties and value of the objects

There are two ways to Spy the objects in QTP
1) Choose Tools-> Object Spy
2) Object repository Dialog

Note:- The Application or object is not visible, hold the Ctrl button and Click or activate the required window to and release the Ctrl button

Object repository in QTP

Understand the Object Repository:
          While Record the Application, Manually Define or Add the Objects it stored into Object Repository. All Objects displayed in the tree view
v  Name:- Name of the Objects
v  Class: Class of the objects
v  Repository : Repository location and Default like “ Local”
v  Test Object details:
v  Description Properties: View/Modify the object’s properties and property value.
v  Ordinal Identifier : It indicate the Identifier Type – Location or Index  and Value 0(Default value)
v  Additional details : it will display Smart Identification is disable or enable and comments
Add the Objects into OR
v  Ctrl+ R (or) Resources -> Object Repository. Select  “Add object to Local” button, highlight the application or window, it will capture all the objects and stored into Object Repository 

Tuesday, June 15, 2010

Recovery scenario manager for QTP

Unexpected events, errors, and application crashes during a running session can disrupt your application and execution section. This is a problem particularly when tests run unattended window or pop-up or Notification. The test pauses until you perform the operation needed to recover.

QTP enables you to create recovery scenarios and associate them with specific tests. Recovery scenarios activate specific recovery operations when trigger events occur.

Define the Recovery scenario
1.    Trigger Event:-
      Pop-up window:-Pops up window an opened the applications during the test run
               Object State: - Object identification issue in our application not match specified value
               Test Run:- Step in your test does not run successfully
               Application crash: Open applications fails during the run times

2.    Recovery Event
     Select the operation to perform when the trigger event occurs
Operation type
               Keyboard or Mouse Operation
               Close application process
               Function call
               Restart the OS (windows)

3.    Post Recovery Event
The recovery operations have been performed and which point in the test or QTP should be continue, the following steps are available in QTP like
     Repeat current Step and Continue
     Proceed to next step
     Proceed to next action or component iteration
     Proceed to next test iteration
     Restart current test run
     Stop the test run

Finally entered the recovery scenario name and saved the operation

Features & Benefits of Quick Test Professional


  • ·         Key word driven and Expert view testing
  • ·         Suitable for both client server, web based application, Oracle Apps, SAP
  • ·         Handling object using Object Repositions manager
  • ·         Descriptive Programming
  • ·         Script language for VB scripts
  • ·         Error handling mechanism
  • ·         Excellent data driven testing features using external File like Excel and Notepad
  • ·         Object Spy and Object Identification feature
  • ·         Verify the file ,text, image and data from database using check points
  • Recovery scenario