Monday, 18 July 2011

What is HWND?


hWND breaks up into h+ WND = handle +Windows. You can reference a window through its handle.A window handle (usually shortened to hWnd) is a unique identifer that Windows assigns to each window created.

Ex- a=Browser("index:=0").GetROProperty("hwnd")
       msgbox a

How to maximize or minimize the Windows using QTP? Or Syntax for Maximize Window


‘Method 1- Using SystemUtil

SystemUtil.Run "iexplore.exe","www.google.com",,,3

‘Here
0-      For close window
2-      For minimize window
3-      For Maximize window

‘Method 2 using Windows Handle property

Dim ie
Set ie=CreateObject ("InternetExplorer.Application")
ie.visible=True
Window("hwnd:=" &ie.HWND).Maximize
ie.navigate "www.google.com"

‘Method 3 – Using Shall Scripts 

Dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.Run "iexplore.exe www.google.com",3 , False
Set wsh = Nothing

Sunday, 17 July 2011

What is the syntax to move to next step in QTP while Error occurred in run time? Or How have to move next step in QTP while Error occurred in Runtime?

Syntax is :-

On Error Resume Next

Example:-

Function browsehome(n_url)

On Error Resume Next ‘have to declare Every function
   SystemUtil.Run "iexplore.exe",n_url
   browsehome="Pass"

End Function

Wednesday, 13 July 2011

Different way to Open the website or application using VB script

'Method 1 using SystemUtil

SystemUtil.Run "iexplore.exe","www.google.com"

'Method2 using without SystemUtil

Option Explicit
Dim a,b
a="www.google.com"
Set b=Createobject("InternetExplorer.Application")
b.visible=True
b.navigate a

'Method3 using Invoke

InvokeApplication "C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.com"

'Method4 using Shall Script

Dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.Run "iexplore.exe www.google.com",3 , False
Set wsh = Nothing

Monday, 11 July 2011

How to Import date from Excel to QTP? And How to Report the status to QTP Report?–Easy Script

'Open Application
app()
Function app()
SystemUtil.Run "flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","Open"
End Function
'import Data's from Excel Sheet to QTP Global Sheet
Datatable.Import"D:\Velmurugan\Learning\Data\Login.xls"
a=Datatable.GetRowCount
msgbox a
login()
'Open Login window
Function login()
   For i=1 to a
   Datatable.SetCurrentRow(i)
  Dialog("Login").WinEdit("Agent Name:").Set datatable.Value("agentname")
   Dialog("Login").WinEdit("Password:").SetSecure datatable.Value("password")
   Dialog("Login").WinButton("OK").Click
   If Window("Flight Reservation").Exist  Then
    'Status to Report
   Reporter.ReportEvent micPass, "Login","Passed"
    Window("Flight Reservation").Close
    Else
    Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
    'Status to Report  
 Reporter.ReportEvent micFail,"Login","Faild"
   End If
  If Not Dialog("Login").Exist(5) Then
  Call app()
 End If
 Next
End Function
--------------------------*-------------------------*-----------------------------------*----------------
Data’s
Ex-

Tuesday, 5 July 2011

Common GUI Test Case for web application


TC-ID
Description
Expected Result
TC-001
Check for the display of the report screen

The Report screen should be displayed without any interruption
TC-002
Check for the Title of the screen
The Title of the screen should be displayed as
TC-003
Check for the title bar of the browser is consistent with the Screen Title
the title bar of the browser should be consistent with the Screen title
TC-004
Check for the address displayed in the address bar of the browser.
The screen path should be displayed with screen name.
TC-005
Check for the contents displayed in the Report Screen
The following contents should be displayed in the From Fortnight Start Date* (Text Box with Calendar Look up), To Fortnight End Date* (Text Box with Calendar Look up) , FEDRO Code (Text Box with Look up), AD Code (Text Box with Look up). Report Format (Combo Box) and Report (Button), Reset (Button) & Close (Button)
TC-006
Check for the enable and disable nature of buttons and fields when the screen is loaded.
The buttons enabled and disabled should be proper as per the specifications.
TC-007
Check display of mandatory fields.
The mandatory fields should contain the red color asterisk (*) symbol on the top right side of the field.
TC-008
Check for the screen layout
The screen layout should be proper as per the
specifications.
TC-009
Check for the Font style, Font Size and Font color of the Screen objects
All the fields should have same Font style, Font Size and Font color as per the requirement specifications.
TC-010
Check for the proper alignment of the Screen objects on screen load
The fields and buttons should be aligned properly without overlapping.
TC-011
Check for the spelling mistakes of the Screen objects
The Screen objects should be devoid from the spelling mistakes
TC-012
Check for the back ground color and the logos used are consistent throughout the application.
The back ground color and the logos used should be consistent throughout the application.
TC-013
Check for the tab movement
The tab movement should be proper as the requirement specifications.
TC-014
Check for the Tool Tips displayed in the screen
Appropriate Tool Tips should be displayed in the screen.
TC-015
Check for the default values displayed on form load
All default values should be displayed properly while loading a page
TC-016
Check for mandatory nature of the From Fortnight Start Date*
Should be displayed Based on the System date, the Text Fields From Fortnight
TC-017
Calendar textbox fields.

Start Date* and To Fortnight Start Date* should display either First or Second Fortnight and 'PDF' should be selected in Report Format Combo box.
TC-018
Calendar lookup window.
The From Fortnight Start Date* calendar should be opened and Cursor should be focused on the Current date and User should be allowed to select required date.


How to retrieve the cookie from webpage using QTP?

A cookie is a small piece of information stored by the browser that applies to a Web page. Each cookie can store up to 20 name=value; pairs called crumbs, and the cookie is always returned as a string of all the cookies that apply to the page.
This means that you must parse the string returned to find the values of individual cookies.
 
 
You can retrieve cookies for a specific URL with two methods:
 
 
Method 1:GetCookies
msgbox Browser("Google").GetCookies("http://www.google.com")
Retrieve value of cookies for a web page with HP QTP
Method 2: Object.cookie
strCookie = Browser("Google").Page("Google").Object.cookie
msgbox strCookie
Retrieve value of cookies for a web page with HP QTP