Wednesday 27 September 2017

Basics of UFT/QTP Testing

UFT/QTP Supported Languages

HP Unified Functional Testing uses VB Script as its scripting language. This is the only language that is fully supported by UFT’s IDE. VB Script supports Object Oriented Programming concepts but not polymorphism and inheritance.

UFT/QTP Supported-Browsers
  • Internet Explorer 6, 7, 8, 9, 10, 11, Edge
  • Firefox 3.0.X, 3.5, 3.6 to 46 
  • Google Chrome till version 56
  • Safari on MAC OS v6 - v9

UFT/QTP Supported OS

Windows 7 (SP1) , Windows 8/8.1 and Windows 10 including Surface support for Windows 8.1 and Windows 10. UFT 12 onward supports Safari on Mac OS (in Beta mode)

As of June 2017, UFT does not support Linux OS.


UFT/QTP System Requirements
  • Computer/Processor: Dual Core CPUs or better
  • Memory: Minimum of 2 GB when no more than three add-ins are loaded  simultaneously. [Additional memory is required when loading more add-ins and when using the Save movie to results option to capture movies during run sessions.
  • Colour Settings: High Colour (16 bit)
  • Graphics Card: Graphics card with 64 MB video memory(Optional)
  • Free Hard Disk Space: 1 GB of free disk space for application files and folders. [You must also have an additional 120 MB of free disk space on the system disk (the disk on which the operating system is installed).

UFT/QTP Support Technologies
Unified Functional Testing comes pre-installed with 4 add ins by default – ActiveX, Visual Basic, Web and Mobile. All-in-all UFT supports .Net, Web, VB, Mobile, Java, Oracle apps, SAP, PeopleSoft, Siebel, Stingray, Terminal Emulators (Unix, Mainframes), Power Builder, Delphi, Visual Age, Web Services, Flex (By Adobe), Shunra VE Desktop Professional for WAN emulation (By Shunra)


UFT/QTP License Types       

Seat License
It’s a license that is specific to the computer on which the tool is installed i.e. if two or more people want to work on the tool then each one of them has to install the seat license on their respective machines.

Concurrent License   
This is a network based license that can be used by multiple users at the same time. This license is installed on a remote license server. Hence a particular number of users can work with the tool by connecting to the license server at the same time.
  
UFT/QTP Cost
Select the desired time period and the number of licenses  
        License Type                                         3 months               6 months                  1 year
   Concurrent                                     $1200                 $2300                   $3500      
    Seat based                                           $800                  $1600                   $2500

UFT/QTP Certification Program 
QTP 11 certification exam was known as Exam HP0-M47: HP AIS – Functional Testing v11(In QTP 11 certification, questions were specific to QTP functionality only)
UFT 12 certification exam is known as Exam HP0-M102: HP Unified Functional Testing 12.x Software.( In exam code HP0-M102 UFT certification, questions were specific to GUI and API functionality and it has been replaced by HPE ATP – Unified Functional Testing v12 with exam code HPE0-M105)                                                                         
HPE0-M105: HPE ATP – Unified Functional Testing v12 (In exam code HPE0-M105 other than GUI and API, a small part of syllabus is also dedicated to LeanFT and UFT Mobile.)


UFT/QTP Usage Example
  1. Click Record button
  2. Open web browser 
  3. Enter the URL of the application.
  4. Enter user id & password and then click on “Login” button on login page.
  5. Click the record button to stop recording
  6. Verify that login is successful
Now consider a case where you have to test this login functionality many a times or you have to test the same functionality for large number of different users say a 1000 or more users.

When should we automate using QTP?
  • Tests that need to run for every build.
  • Tests that use multiple data values for same action.
  •  Identical tests that need to be executed using different browsers

When should not we automate using QTP?
  •        Test Cases that will only be executed once.
  •         Test Cases used for Ad-hoc/random Testing.
  •         Test Cases that are infrequently selected for execution.
  •        Test Cases that will require manual intervention ie a task not possible to automate.
  •         The most imp. one–based on the intuition and knowledge of application. Eg. if you find that you cannot escape from manual intervention.

Variable Declaration
Variables in VB Script can be declared in three ways:
  • Dim Statement
  • Public Statement
  • Private Statement

For example:
Dim No Passenger

Multiple variables can be declared by separating each variable name with a comma.


For example:  
Dim Top, Left, Bottom, Right


Option explicit
If you misspell for example the "myname" variable to "mynam", the script will automatically create a new variable called "myname". To prevent your script from doing this, you can use the 'Option Explicit' statement.
Put the Option Explicit statement on the top of your script. Like this:
Option Explicit
Dim myname
myname = "Santhosh"
If we use 'Option Explicit', then we must declare the
variable before we use.
If you don’t declare the variable, then it returns an error
message.

Naming Convention
There are standard rules for naming variables in VB Script.

A variable name:
  1. Must begin with an alphabetic character.
  2. Cannot contain an embedded period.
  3. Must not exceed 255 characters.
  4. Must be unique in the scope in which it is declared.
 Assigning Values to Variables
       Example: 

B = 100

      Scalar Variables and Array Variables
      Example:

      Dim A(10)

 A variable containing a single value is a scalar variable. Assigning more than one related value to a single variable is called an array variable.

    Key Points: 
  • CTRL+SHIFT+F3 is used to Start/End analog recording mode
  • The list of test objects and their properties and values are stored in the Object Repository
  • GetROProperty is used to retrieve the current property value of the objects in your application during the run session
  • Bitmap checkpoint is supported in VB environment
  • F12 is the shortcut key that is used for a Standard Checkpoint
  • You can replace the page in your Active Screen tab


Components of the IDE
1.      Menu bar
2.      Properties window
3.      Document tab
4.      Solution Explorer
5.      Toolbox tab
6.      Output tab
7.      Active Screen
8.      Data tab

Start Page

If you do not want QTP to display the Start Page when you next open QTP, select the "Don't show the Start Page window on start up" check box. When you select this option, the Start Page is also automatically hidden for the current QTP session as soon as you open another QTP document. To display the Start Page again,
select View > Start
Solution Explorer:
The Solution Explorer is a hierarchical tree of all actions and tests in the current test, with their references, events and flows






Properties:

Detailed information of the function will appear on the right side of the panel under "Properties" panel



Data Table:

You can enter the data related to your test through data-tab from the menu-bar at the bottom of the window. This panel is the tree hierarchy of data sources that can be used with test. 



Action:

The "Action" tab gives details of test code





Errors:
To view the errors encountered during performing automation testing, you can use the error tab from the bottom panel.



QTP window panes

You can move the QTP window panes to suit your own personal preferences.
Say we want to Move the Solution Explorer.
In the QTP window, drag the title bar of the Solution Explorer.
As you drag the pane, markers are displayed in the active pane and on each edge of the QTP window.
Drag the Solution Explorer and hold the cursor over the various markers. A shaded area is displayed, indicating the new location of the pane. Let's move it to Top. Release the mouse button. The Solution Explorer Pane snaps into place and is displayed as a new pane in the shaded area. 

Steps to Record a Script in QTP

Step 1: In QTP click the record button. The Record and Run settings Dialog Box Opens. This box opens automatically each time you begin recording a new test

Step 2: Record & Run settings shows a tabs corresponding to add-ins installed and loaded for your test. So, for example if you have SAP Add-in Installed and loaded you will see a SAP tab. The Windows Application tab is always available and be used for environments, such as  Visual Basic, ActiveX, and terminal emulators.

For any Environment, the Record and Run settings can be classified into two generic groups
  1. Record & Run on ANY window belonging to that particular environment
  2. Record & Run on a SPECIFIC window belonging to that particular environment - which is the recommended Option


For the time being , lets stick to default settings .Once settings are done , QTP remembers and uses the same settings for additional record sessions on the same test, unless you manually open the Record and Run Settings dialog box to modify the settings.

Step 3: Click okay. QTP Starts Recoding Mode


Step 4: Record the  test steps.  Stop recording. Save the script as "Login.

Test Results for QTP





Right Hand Side shows Test Results Summary.

Left Hand Side is Test Results Tree - an icon-based view of the test steps that were performed while the test was running. Similar to the test tree in Keyword View 


      You can capture Movie / Screenshots of entire Test Run using Tools > Options > GUI Testing



     












         You can print/export the results












You can exports the results/defects to Quality center.

Parameterization:
Parameterization enables you to run the same QTP test for different test data. Checkpoints adjudicate the pass or fail status to your automation tests. 

Example: 





To achieve this, you can either copy the six steps or give different data values that are in fact something you would do manually, or you can use Parameterization. 









The easiest way to parameterize an argument, in our case is
  1. Click Keyword View
  2. Click the parameterization Icon.






Error Types:

  •          Syntax errors
  •          Logical errors
  •          Run time errors
               Syntax errors:
      Syntax errors are the typos or a piece of the code that does not confirm with the VB scripting language grammar. Syntax errors occur at the time of compilation of code and cannot be executed until the errors are fixed.

             To verify the syntax, use the keyboard shortcut Ctrl+F7 the result is displayed. If the window is not displayed you can navigate to "View" → "Errors".
             Logical errors:
             If the script is syntactically correct but it produces unexpected results, then it is known as a Logical error. Logical error usually does not interrupt the execution but produces incorrect results. Logical errors could occur due to variety of reasons, viz- wrong assumptions or misunderstandings of the requirement and sometimes incorrect program logics (using do-while instead of do-Until) or Infinite Loops.
         
            Run time errors:
            This kind of error happens during Run Time. The reason for such kind of errors is that the script trying to perform something is unable to do so and the script usually stops, as it is unable to continue with the execution. Classic examples for Run Time Errors are
  •            File NOT found but the script trying to read the file
  •            Object NOT found but the script is trying to act on that particular object
  •            Dividing a number by Zero
  •            Array Index out of bounds while accessing array elements


Thanks for Reading…. J

-By Vikasini