Sunday 28 October 2012

Inserting Output Values



It is a step in which one or more values are captured during test execution.

The values can later be used as input at a different point in the run session or we can use as input for another test.

It is stored in run time data table; it is located in QTP result window and can be retrieved later.

Types of Output Values:

1.       Standard output value
2.       Text output value
3.       Text area output value
4.       Database output value
5.       XML output value (From Application)
6.       XML output value (From Resource)


1) Standard output value:

 We can use standard output values to output the properties values of most objects.

Navigation:

Keep tool under Recording mode > Insert menu >output value> standard output value > show the object > click ok > select property > modify the column name (if required) > click ok >click ok >stop recording.

2) Text output value:

We can use Text output values to output text strings displayed in an application. When creating a text output value we can output a part of the objects text and we can also specify text before and after options.

Navigation:
Keep tool under recording mode> Insert menu> output value > text output value > show the text >select one of the option(output text/text before/text after) > click modify if you want to change the column name > click ok > click ok.> check in runtime table after running it.

3) Text Area output value:

We can use text area output values to output text strings displayed within a defined area of the screen.

Navigation:

Keep tool under recording mode > insert menu >output value > text area output value >Mark the text area >click modify the column name if necessary > click ok > again click ok > check in run time table after running it..

4) Database output value:

We can use Database output values to output the value of the contents of database cells.

Navigation:

Insert menu> output value > Database output value> choose specify SQL statements manually >click next >click create >Select Machine Data source > Select Driver (QT_flight32) > click ok > enter SQL statement (select *from orders) > click finish > select data cells > click ok > Run and it will capture and see the results in run time table.

5) XML output value (from application):

we can use XML output values to output the values of XML elements in XML documents.

Navigation: Keep tool under recording mode with web environment > Insert menu > output value > XML output value from application > Show the XML document > select elements > click ok >stop recording.

6) XML output Value (From Resource):

We can use XML output values to output the values of   XML elements in XML documents.

Navigation:

Insert menu >output value> XML output value from resource > browse path of the XML file > click ok > select elements >click ok.



Inserting Checkpoints



Check point is a verification point, it takes expected result from the user and compares with actual results during execution and provides test results.

There are 11 Checkpoints available in QTP:

1.      Standard check point
2.      Text check point
3.      Text area check point
4.      Bit map check point
5.      Data base check point
6.      Accessibility check point
7.      XML Check point (from Application)
8.      XML Check point (from Resource)
9.      Page check point
10. Image checkpoint
11. Table checkpoint

Note 1: From 6 to 11 checkpoints are only for Web.

Note 2: From 9 to 11 checkpoints are hidden checkpoints, we can insert these checkpoints through standard checkpoint.


1.    Standard Checkpoint:

It checks object property values. We can use this checkpoint for checking any property value.

Navigation for Inserting standard checkpoint

Keep tool under recording mode > place cursor in desired location > Insert > check point > Standard checkpoint > Show the object  > click okay > select property and enter expected results & click Ok and stop Recording.

Navigation for Editing standard checkpoint

Select Checkpoint statement and right click > choose checkpoint properties option > modify the value > click Ok.

Navigation for Deleting standard checkpoint:

Select Checkpoint statements and right click > choose delete option.

Inserting Standard check points through active screen:

View > Active Screen >place cursor in desired location >Place mouse pointer on active screen & right click> choose insert standard checkpoint option > click ok > enter expected result > click ok

Note: Inserting Standard check points through keyword view same as in expert view.

Note: We can insert standard checkpoints in 3 ways.

a.      Through expert view,
b.      Through keyword view,
c.      Through Active screen.

2) Text Checkpoint:

 It Checks object’s text property value in different ways.

Navigation:
Keep tool under Recording mode >Insert menu > checkpoint > Text checkpoint > Show the object > click ok > Select options

(Match case; ignore spaces, exact match, text not displayed.)

We can select one or more options > click ok & stop Recording.

3)  Text Area Checkpoint:

It checks the text area present in the application.

Navigation:
Keep tool under Recording mode > Insert menu> Checkpoint > Text area checkpoint > Mark the area of text > select one or more options

(Match case, ignore spaces, exact match, text not displayed.)

Click ok and stop recording.

4.      Bitmap checkpoint:

It compares bitmaps; we can compare complete bitmaps as well as part of the bitmaps.

Navigation:

Keep tool under Recording mode > Insert menu > Checkpoint > Bitmap checkpoint > show the Bitmap >click ok >select “check only selected area” option if we want to compare part of the bitmap > click ok >stop recording.

5.      Database checkpoint:

It checks Content of the back end Database.

Navigation:
Insert > checkpoint > Database checkpoint >choose “specify SQL statement manually” option >click next > click create > select machine data source > Select DSN (QT_flight32) > click ok > enter SQL statement (select * from orders) > finish > click ok.

Note: here we do not need to put tool under Recording mode and we do not need AUT since data is from backend.

6.      Accessibility check point:

It checks whether the webpage in our web application is developed according to W3C (World Wide Web consortium) Rules and Regulations or not.

It is a configurable checkpoint, according to our requirements, we can customize.

Configuring accessibility checkpoint:

Tools menu> options >web > advanced > check/uncheck items > click apply > click ok

Invigilation:
Keep tool under recording mode with web environment >insert>checkpoint>accessibility checkpoint>show the webpage>click ok>click ok>stop recording.

Result Criteria:
a)     If item is available but not according to W3C rules then fail.
b)     If an item is available, according to W3C rules then Pass.
c)     If an item is not available then result would be pass

7. XML Check point (from Application)

It checks content of the XML file.

Navigation:
Keep tool under Recording mode in web environment > insert menu > checkpoint (from application)> show the xml pages >click ok > stop Recording.

8. XML Check point (from Resource)

It checks content of the XML file.

Navigation: Insert menu > checkpoint >xml checkpoint (from resource) > browse path of the XML File > click ok > click ok.

Note: 1. If XML file is an individual and path available, and then we can go for inserting xml checkpoint from resource.

Note: 2. If XML file is part of web application, separate path is not available then we can choose inserting XML checkpoints from application.

9. Page checkpoint:

It checks number of Links, Images and Loading time in a web page.

It is a hidden checkpoint; we can insert this through standard checkpoint.

Navigation:

Keep tool under Recording mode with web environment > Insert menu > checkpoint > Standard checkpoint >show the web page > click ok > click ok > stop recording.

10. Image checkpoint:

It checks Image property values.

Navigation:
 Keep tool under Recording mode with web environment > Insert menu > checkpoint >standard checkpoint > show the image > select image > click ok > click ok >stop recording.

11. Table checkpoint:

It checks content of the web tables.

Navigation: Keep tool under Recording mode under web environment > Insert menu > checkpoint > standard checkpoint >show the web table > click ok >stop recording.


File System Operations 2


10) Counting the number of times a word appears in a file

sFileName="E:\gcr.txt"
sString="gcreddy"
Const FOR_READING = 1
Dim oFso, oTxtFile, sReadTxt, oRegEx, oMatches
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oTxtFile = oFso.OpenTextFile(sFileName, FOR_READING)
sReadTxt = oTxtFile.ReadAll
Set oRegEx = New RegExp
oRegEx.Pattern = sString
oRegEx.IgnoreCase = bIgnoreCase
oRegEx.Global = True
Set oMatches = oRegEx.Execute(sReadTxt)
MatchesFound = oMatches.Count
Set oTxtFile = Nothing : Set oFso = Nothing : Set oRegEx = Nothing
msgbox MatchesFound

11) Read a CSV File Using Database Techniques

On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

strPathtoTextFile = "C:\Databases\"

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=" & strPathtoTextFile & ";" & _
          "Extended Properties=""text;HDR=YES;FMT=Delimited"""

objRecordset.Open "SELECT * FROM PhoneList.csv", _
          objConnection, adOpenStatic, adLockOptimistic, adCmdText

Do Until objRecordset.EOF
    Wscript.Echo "Name: " & objRecordset.Fields.Item("Name")
    Wscript.Echo "Department: " & _
        objRecordset.Fields.Item("Department")
    Wscript.Echo "Extension: " & objRecordset.Fields.Item("Extension")  
    objRecordset.MoveNext
Loop

12) Read a Text File into an Array

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("e:\gcreddy.txt", ForReading)

Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")
    Wscript.Echo "Server name: " & arrServiceList(0)
    For i = 1 to Ubound(arrServiceList)
        Wscript.Echo "Service: " & arrServiceList(i)
    Next
Loop

13)  'Calculate size of a Text file

Dim objFso, File1,File2
File1="C:\Documents and Settings\1 RIGHATWAY\Desktop\xyz.txt"
Set objFso=CreateObject("
Scripting.FileSystemObject")
x= objFso.GetFile(File1).Size
Msgbox x& "  Bytes"

14) 'Test Requirement: Open 1 to 10 orders in Flight Reservation , Capture Customer names and Export into a Text file

'Test Flow:
'Login Operation
'Open Order Operation and form the Loop to open 1 to 10 Orders
'Capture Cusomer names using GetROProperty Method
'Create File system Object and Open the Text file using  the Object and Export Cusomer names
'----------------------------------------------------------------------------
Option Explicit
Dim Order_Number, Customer_Name, objFso, myFile
Set objFso=CreateObject("Scripting.FileSystemObject")
Set myFile= objFso.CreateTextFile ("C:\Documents and Settings\1 RIGHATWAY\Desktop\abcNew.txt",2)
myFile.WriteLine "Cusomer Names"
myFile.WriteLine "--------------------"
If Not Window("Flight Reservation").Exist(3)  Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "4c48590870466b8dc050bbd24e816890c747ccf8"
Dialog("Login").WinButton("OK").Click
End If
For Order_Number= 1 to 10 step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set Order_Number
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Customer_Name = Window("Flight Reservation").WinEdit("Name:").GetROProperty("text")
wait (2)
myFile.WriteLine Customer_Name
Next
myFile.Close
Set objFso=Nothing

15)
'******************************************************
'Test Requirement: 
Capturing all Buttons Names from the Login Dialog box and exporting to a Text file