Thursday 7 November 2013

UFT/QTP- Automation Object Model

qtp aom documentation, qtp aom results, qtp aom script, qtp automation object model, qtp automation object model reference





Automation Object Model

Automation object model is nothing but collection of objects, methods and properties which are used to perform quicktest operations. Throughout this object model we can perform any operation described in QTP interface. For every option in QTP menus (Interface) have Objects, methods and properties are there in this model.

AOM is the concept to automate QTP itself.

-----------------------------------------------------------------------------------------------------------------------

Automatically Start  QTP, open an existing test and Run the Test:
Dim App
Dim qtTest

'Create the QTP Application object
Set App = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If  App.launched <> True then

App.Launch

End If

'Make the QuickTest application visible
App.Visible = True

'Set QuickTest run options
'Instruct QuickTest to perform next step when error occurs

App.Options.Run.ImageCaptureForTestResults = "OnError"
App.Options.Run.RunMode = "Fast"
App.Options.Run.ViewResults = False

'Open the test in read-only mode
App.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", True

'set run settings for the test
Set qtTest = App.Test

'Instruct QuickTest to perform next step when error occurs
qtTest.Settings.Run.OnError = "NextStep"

'Run the test
qtTest.Run

'Check the results of the test run
MsgBox qtTest.LastRunResults.Status

' Close the test
qtTest.Close

'Close QTP
App.quit

'Release Object
Set qtTest = Nothing
Set App = Nothing


Start  QTP, open an existing test and Run the Test  And Store Run Results in Specified Folder:

Dim qtApp
Dim qtTest
Dim qtResultsOpt

'Create the QTP Application object
Set App = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If  App.launched <> True then

App.Launch

End If

'Make the QuickTest application visible
App.Visible = True

'Set QuickTest run options
App.Options.Run.ImageCaptureForTestResults = "OnError"
App.Options.Run.RunMode = "Fast"
App.Options.Run.ViewResults = False

'Open the test in read-only mode
App.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", True

'set run settings for the test
Set qtTest = App.Test

'Instruct QuickTest to perform next step when error occurs
qtTest.Settings.Run.OnError = "NextStep"

'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")

'Set the results location
qtResultsOpt.ResultsLocation = "D:\Result"

' Run the test
qtTest.Run qtResultsOpt

'Check the results of the test run
MsgBox qtTest.LastRunResults.Status

'Close the test
qtTest.Close

'Close QTP
App.quit

'Release Object
Set qtResultsOpt = nothing
Set qtTest = Nothing
Set App = Nothing


Start QTP and open New test:

Dim App
Dim qtTest

'Create the QTP Application object
Set App = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If  App.launched <> True then
App.Launch
End If

'Make the QuickTest application visible
App.Visible = True

' Open a new test
App.New

Set App = Nothing ' Release the Application object


Start QTP, open an existing test, associate Object Repositories and save the test:

Dim App
Dim qtTest
Dim qtRepositories

'Create the QTP Application object
Set App = CreateObject("QuickTest.Application")
'If QTP is notopen then open it
If  App.launched <> True then
App.Launch
End If

'Make the QuickTest application visible
App.Visible = True
App.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False

' Get the object repositories collection object of the "SignIn" action
Set qtRepositories = App.Test.Actions("SignIn").ObjectRepositories

' Add  Object repositry "Reposit.tsr" if it's not already associated wit action "SignIn"

If qtRepositories.Find("D:\Reposit.tsr") = -1 Then
    qtRepositories.Add "D:\Reposit.tsr", 1
End If

'Save the test
App.Test.Save

'Close QTP
App.quit

'Release Object
Set qtLibraries = Nothing
Set qtTest = Nothing
Set App = Nothing

 -----------------------------------------------------------------------------------------------------------------------

Start QTP, open an existing test, associate libraries and save the test:

Dim App
Dim qtTest
Dim qtLibraries

'Create the QTP Application object
Set App = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If  App.launched <> True then
App.Launch
End If

'Make the QuickTest application visible
App.Visible = True

App.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False

'Get the libraries collection object
Set qtLibraries = App.Test.Settings.Resources.Libraries

'If the library file "libraary.vbs" is not assiciates with the Test then associate it
If qtLibraries.Find("D:\libraary.vbs") = -1 Then
    qtLibraries.Add "D:\libraary.vbs", 1 
End If

'Save the test
App.Test.Save

'Close QTP
App.quit

'Release Object
Set qtLibraries = Nothing
Set qtTest = Nothing ' Release the Test object
Set App = Nothing ' Release the Application object


Generating script for QTP Settings and QTP Options for AOM

Defining Settings in QTP

To know, how settings are defined and QTP object is launched, and settings are defined using AOM, Go to File>Settings>Properties and click on Generate Script. This will generate a script with all the default setting parameters



The Content of the script will be as follows:
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Test.Settings.Launchers("Web").Active = False
App.Test.Settings.Launchers("Web").Browser = "IE"
App.Test.Settings.Launchers("Web").Address = "http://www.rediff.com"
App.Test.Settings.Launchers("Web").CloseOnExit = True
App.Test.Settings.Launchers("Windows Applications").Active = True
App.Test.Settings.Launchers("Windows Applications").Applications.RemoveAll
App.Test.Settings.Launchers("Windows Applications").RecordOnQTDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnExplorerDescendants = False
App.Test.Settings.Launchers("Windows Applications").RecordOnSpecifiedApplications = True
App.Test.Settings.Run.IterationMode = "rngAll"
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Run.ObjectSyncTimeOut = 20000
App.Test.Settings.Run.DisableSmartIdentification = False
App.Test.Settings.Run.OnError = "Dialog"
App.Test.Settings.Resources.DataTablePath = "<Default>"
App.Test.Settings.Resources.Libraries.RemoveAll
App.Test.Settings.Web.BrowserNavigationTimeout = 60000
App.Test.Settings.Web.ActiveScreenAccess.UserName = ""
App.Test.Settings.Web.ActiveScreenAccess.Password = ""

Defining Options in QTP

To know the current options settings in QTP, we can generate a script similar to Settings as defined above through Tools>Options>General and clicking on generate scripts.


Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Options.DisableVORecognition = False
App.Options.AutoGenerateWith = False
App.Options.WithGenerationLevel = 2
App.Options.TimeToActivateWinAfterPoint = 500
App.Options.SaveLoadAndMonitorData = True
App.Options.Run.RunMode = "Fast"
App.Options.Run.ViewResults = True
App.Options.Run.StepExecutionDelay = 0
App.Options.Run.MovieCaptureForTestResults = "Never"
App.Options.Web.AddToPageLoadTime = 10
App.Options.Web.RecordCoordinates = False
App.Options.Web.RecordMouseDownAndUpAsClick = False
App.Options.Web.RecordAllNavigations = False
App.Options.Web.RecordByWinMouseEvents = ""
App.Options.Web.BrowserCleanup = False
App.Options.Web.RunOnlyClick = False
App.Options.Web.RunMouseByEvents = True
App.Options.Web.RunUsingSourceIndex = True
App.Options.Web.EnableBrowserResize = True
App.Options.Web.PageCreationMode = "URL"
App.Options.Web.CreatePageUsingUserData = "Get Post"
App.Options.Web.CreatePageUsingNonUserData = ""
App.Options.Web.CreatePageUsingAdditionalInfo = True
App.Options.Web.FrameCreationMode = "URL"
App.Options.Web.CreateFrameUsingUserData = "Get Post"
App.Options.Web.CreateFrameUsingNonUserData = ""
App.Options.Web.CreateFrameUsingAdditionalInfo = True
App.Options.WindowsApps.AttachedTextRadius = 35
App.Options.WindowsApps.AttachedTextArea = "TopLeft"
App.Options.WindowsApps.ExpandMenuToRetrieveProperties = True
App.Options.WindowsApps.NonUniqueListItemRecordMode = "ByName"
App.Options.WindowsApps.RecordOwnerDrawnButtonAs = "PushButtons"
App.Options.WindowsApps.ForceEnumChildWindows = 0
App.Options.WindowsApps.ClickEditBeforeSetText = 0
App.Options.WindowsApps.VerifyMenuInitEvent = 0
App.Options.TextRecognitionOrder = "APIThenOCR"

App.Folders.RemoveAll

Tuesday 15 October 2013

UFT/QTP- Object Identification in UFT

UFT Objects identification process:

The below mentioned is workflow of object identification, relate the WF with the scenario


UFT Objects identification process

Work flow of Object identification process

Scenario: -

 You are going for a meeting with a person called John for the first time. You haven’t met him before and only option of recognizing John is the description given by your boss.

Description of John:-

Destination: - Taj (Hotel name.), Blue entry gate.
Hotel location:-Third hotel in Kings Street.
Accessories/height:-Black coat, Blue tie, Ray ban specks, and 6 feet

Solution:-
So here you are like UFT and John is Object. So your task is to find object.
  
What will be our approach?

Step1: Reaching the destination with the help of hotel name,Taj(Mandatory Property),Blue gate(Assistive Property), and that it is the third hotel in Kings Street as told by your boss (Visual Relation identifier)

Step2: -After reaching hotel, UFT is looking for the Person with black coat, blue tie, 6 feet height (Smart identification), Ray ban (it is dark inside the hotel, thus this property is not used by UFT)

Step3:- Now problem is that there are 2 person which are of same height, wearing black coat , blue tie, now you are stuck, here comes the final shot(Ordinal identifier), you call your boss(we don’t have John phone number J), he tells that he is currently standing right in front of help desk(This is ordinal identifier property called Location).Here you finally found John.

In case you (UFT) is not able to find John (object) so meeting never happened (UFT throws error) and hope your boss is great enough, that this is not affecting your appraisal J.

 So the basic approach of UFT is to store some identifiers, i.e.  object properties so that it can be used at Run time, to uniquely identify the object and required action on that object can be performed or testing of the object is possible.

Monday 30 September 2013

UFT/QTP- Synchronization


how to use sync method in qtp, sync in qtp, sync method in qtp, syntax for sync in qtp


Synchronization:

Synchronization point is nothing but time interface between Tool and Application build. Generally Synchronization point is to give waiting time to the tool before executing next step in Test script.

Different methods in QTP for Synchronization:

1. Wait statements.
2.  Exist Statements.
3. Sync Method (Only for WEB).
4. Inserting Synchronization points.
5. Increasing Tool default synchronization time.

Wait Statements:

Wait statements are used when we want QTP to wait for specified time, so that AUT completes its current operations.
Wait (n) statement waits for specified 'n' seconds.
Wait () statement without specifying the seconds will make QTP wait up to maximum time, even though operations is completed.

Example:

Systemutil.Run "iexplore.exe","http:\\www.gmail.com"

 ‘Wait for 5 sec for Gmail browser launch
Wait 5

 ‘Enter Email id in Username Field
Browser ("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Email").Set  "qtpworld.com"

 'Enter password in Password Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Passwd").Set  "qtp"

 'Cick on the Sign In Button
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebButton("name:=Sign in").Click

Exist Statements:

We can enter Exist statements to instruct QuickTest to wait for a window to open or an object to appear. Exist statements return a boolean value indicating whether or not an object currently exists.

Example:

Systemutil.Run "iexplore.exe","http:\\www.gmail.com"

 'Wait till Gmail browser exists
Do while  Browser("title:=Gmail: Email from Google").Exist(1) = False
 Wait 1
Loop

 'Enter  Email id in Username Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Email").Set  "qtpworld.com"

 'Enter password in Passowrd Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Passwd").Set  "qtp"

 'Cick on the Sign In Button
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebButton("name:=Sign in").Click

 Sync Method: (only for WEB)

Waits for the browser to complete current navigation operation.
Syntax:
Object hirearchy.Sync
Example:

 Systemutil.Run "iexplore.exe","http:\\www.gmail.com"

'Wait till Gmail browser launches
Browser("title:=Gmail: Email from Google").Sync

' Enter  Email id in Username Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Email").Set  "qtpworld.com"

 'Enter password in Password Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Passwd").Set  "qtp"

 'Cick on the Sign in Button
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebButton("name:=Sign in").Click

 Inserting Synchronization points:

Synchronization point is nothing but time interface between Tool and Application build. Generally Synchronization point is to give waiting time to the tool before executing next step in Test script.
Steps to follow for Inserting Synchronization points:

Position cursor in desired location-->QTP should be in recording mode-->Insert menu-->Synchronization point -->Show the object -->click OK-->select property name and Value (True)-->enter time in Milli seconds-->click OK-->Stop recording.

Increasing Tool default synchronization time:

Default Time in QTP is 20 Seconds.

Steps to follow for Increasing default synchronization time:

File-->settings-->run tab-->increase object synchronization time out-->Apply-->OK

Wednesday 4 September 2013

uft 11.5 trial version installation

Download UFT 11.5 Trial Version from HP

HP has released the latest version of QTP and it is being called HP Unified Functional Testing (UFT) 11.5. As mentioned in the previous article on the features of the new UFT 11.5, the trial version of UFT 11.5 is now available for download from HP website. The trial period of the software is 30 days.
You can either check the below video or follow the step by step approach (provided after the video) to download UFT 11.5 from HP website.

Steps to Download UFT (QTP) 11.5 from HP website

1) Go to UFT 11.5 download link. You will be navigated to the page shown in the below screenshot.



2) Click on the trial software section to expand it. Once expanded, you will see the links for various trial software that are currently available for download.




3) Click on ‘HP Unified Functional Testing 11.50 CC English SW E-Media Evaluation’link. You would be taken to a page where you would need to provide your personal details as shown below.


4) Enter all the mandatory details and then click on Next button at the bottom of the page. If all the details are filled in correctly, you will be navigated to the ‘Terms of Service’ screen as shown below.
5) Click on “I Agree” to move to the main download screen as shown in the below image.


6) Click on the Download link to download the software. The software will be downloaded as a ZIP file.
As shown in the above image also, the size of UFT 11.5 is around 1.7GB. Downloading the software will take 1-2 hours (depending upon the internet speed).

Tutorial - Go to Websites Script on UFT Mobile

uft mobile tutorial

The UFT version of this script, is split into three actions:
Pre:

The home command brings the phone to its idle state and it is recommended to start all scripts with it as they allow us to start from a known location.

Action:





This action loops over a data table, with a local data table and a call property running on all rows.
























WebBrowser.Goto

This command, opens the browser and directly it to a URL. The URL comes from the data table.
This command is available on Android and iOS devices.

















Wait

This command waits for the time specified to pass. It is used here to give the browser time to load the page. 
It is also possible to create a more advanced sync function that will check the screen of the phone to determine when the page has loaded.

Post




It is good practice to end the script in the home screen, so the home command is used at the ending as well as the beginning of the script