RSS Feed

Monthly Archives: March 2015

UTF 12.0 First Look After Installation

First look of QTP/UFT 12.0 after installation:

In previous article we have seen “Overview of HP Unified Functional Testing 12.0“. In today’s article taking first look of UFT tool.

1) After Installation, start the application either; from desktop shortcut or from Start Menu.

QTP 12.0 automatically creates desktop shortcut after installation process done, use the desktop shortcut to launch the QTP 12.0.

Also, you can start the QTP from Start > All Programs > HP Software > HP Unified Functional Testing, as shown in the figure below.

firstlook-of-qtp-uft-12-0-after-installation

2) Once you open UFT 12.0, the first window will be the License window. If you have already chosen the Seat (Trial) license at the time of installation then click on “Continue” button else click on “Install License” button.

uft-12-0-license-window

3) The next window will be the license type window, choose any one of the license type shown in the figure below, to install the license type.

UFT-12.0-license-type

4) When you click on “Continue” in the license warning window, the next window will be the Add-in Manager window, select the required add-ins from the list that should be suitable to your application which you are going to test using UFT 12.0 then click on “OK”.

UFT-12.0-Add-In-Manager

5) After loading the required add-ins, the UFT 12.0 application window opens, which will display as shown in the figure below.

UFT-12.0-Start-Up-Window

Let’s start the working process of UFT 12.0
The first and simple test formation technique in UFT is record and playback.During the functional testing of the application, Record function records the user actions of the application to automatically generate the scripts that can be played back later. Using record function, users can automation build scripts without knowledge of any scripting language.

Recording modes in UFT 12.0
There are different modes of Recording in UFT 12.0,

UFT-12.0-Recording-modes

1) Normal Recording: It is a default recording mode that records the objects functions and operations implemented on the application under test.

2) Analog Recording: At the time of recording an application functional operation under test, the exact mouse and keyboard operations can also be recorder relative to the that particular application. In this recording mode, each and every movement of the mouse as you drag the mouse around a screen or window can be recorded. This mode is valuable for recording operations that cannot be recorded at the level of an object, for example, recording a signature produced by dragging the mouse.

3) Low-Level Recording: Permits user to record any object of the application. Recording happens at the object level and records all run-time objects as Window or WinObject test objects. Use low-level recording technique, useful to record exact coordinates of the object under test.

4) Insight Recording: In this case, record operation happens based on its appearance, not on its native properties.

Operation of Record and Playback function

Working process of Record and Playback function in Normal recording mode is as follows,

1) In the start page of UFT, click on”New” as shown below in the figure.

UFT-12.0-Start-New-Test

2) After Clicking on “New” option, the new test window opens with various test types, here GUI test type has been automatically selected, by default. But, user can also select the test type from the list as per their requirement. So, select the test type (GUI Test) from the list, change the Name and Location if you want then click on “Create” to save the test in a particular location with particular name.

UFT-12.0-Start-GUI-Test

3) Next,a new test window screen opens as shown below. Here, click on “Action1″ Tab for further process.

UFT-12.0-Action-1

4) The Action1 window will look like the figure as shown below with1 action, by default.

UFT-12.0-Start-Action-1

5) In the Action1 window, from “Record” Menu select “Record and Run Settings” as shown below.

UFT-12.0-Record-and-Run-Settings

6) In the Record and Run Settings Dialog window, user can go to any tab (Web or Windows Applications) depends on the type of application on which you are working. For example; here you will get the recording process of a Web Based Application: “http://easycalculation.com/” on Mozilla Firefox.

User can also choose the Web browser on which the web application will open, the default selection is Microsoft Internet Explorer. UFT 12.0 supports all browsers shown in the figure below.

After doing required on the Record and Run Settings Dialog window, first click on Apply then OK.

UFT-12.0-Record-and-Run-Settings-Dialog

7) Next, click the Record Button.

UFT-12.0-Start-Recording

8) Once user click on Record button, Mozilla Firefox automatically opens URL: http://easycalculation.com/ as per the settings. In this particular Web address, whatever action you will do, scripts will generate for that particular action. After recording process done, click on stop button and go back to the UFT user interface, generated scripts will be shown in Action1 Pane as shown in the figure below.

UFT-12.0-Generated-Script

9) Now playback the script by clicking on the playback (Run)button to display desired result.

UFT-12.0-Run-recorded-the-script

10) At last, the result window will display as shown in the figure below.

HP-UFT-12.0-Run-Result-Viewer

How scripts generate in all recording modes:

After clicking on Recording button, one toolbar appears that facilitates user to choose the recording mode from the recording pane that appears on the screen once recording starts.

UFT-12.0-Recording-modes

Let do this with the example of the URL: http://easycalculation.com/ Go to, Tax Calculator > Chine Income > Taxable Income > Calculate.

Recording in Normal Mode: Script generated using above example.

UFT-12.0-Recording-in-Normal-Mode

Recording in Analog Mode: Script generated using above example.

UFT-12.0-Recording-in-Analog-Mode

Recording in Low-Level Mode: No script generated.

Recording in insight Mode: Script generated using above example.

UFT-12.0-Recording-in-insight-Mode

Advertisements

QTP Tutorial 3 : Adding Standard Steps From Keyword View

Adding Standard Steps From Keyword View

In last tutorial we saw how to work with keyword view.

Today’s article is going to be about adding steps to a QTP test from the keyword view. Before we go about adding the steps, let’s see what kind of steps we can add at all:

  1. Standard Step: A standard step is anything that acts on an object. For example, a set operation on an edit box with a particular value or selecting a value from a list box.
  2. Checkpoint Step: Checkpoint is a step in a QTP Test that compares an expected value of a specific property/state of an object with the actual value. This is a kind of validation that QTP provides to the users to make sure their AUT is working as intended. So, when this kind of a step is inserted, QTP performs a check during this step execution and if expected and actual values are same, the checkpoint passes or else it fails. An example of a checkpoint is, if in an application a checkbox is supposed to be ON after its selected or a particular name that a text on the screen should be, etc. QTP has 10 checkpoints that it provides the users with. Apart from these, the tester can verify and validate any conditions by programmatically writing them. All the check points will be dealt in detail in the coming articles.
  3. Output value: As the name implies an output value is nothing but a variable that stores the outcome of a particular step in a test. This value can be used subsequently as an input for another step. This value is only available for the time period of a test run after which it gets reset. This topic also will be detailed out shortly.
  4. Comments: Any step that is a non-programmatic and won’t be executed, but is put in the script to increase readability is a comment.
  5. Conditional and Loop statement.
  6. Other: These are the kind of statements that help in designing the programming logic. Some examples are sync statement, writing into test results etc.

Let’s start with adding a standard step. For our convenience I am going to explain the use of only item, operation, value and documentation columns in the keyword view. Though there are two more columns, they are seldom used.

Inserting a step is the first part of adding a line to a program. A step merely adds a blank line in your test. It is up to the tester to define the step and to add details to the step. The details include what item to act on, what operation to perform, what value to assign etc. If it’s a new test, any step we are trying to add becomes the first step. From the menu main, select Insert-> New Step after clicking anywhere in the keyword view.

1

Another way is to right click on an existing step and selecting Insert new step from the menu.

2

Both of these option result in the addition of a new line after the selected step. If a container object was selected while adding a new line, the new step gets added as a sub-step. If a last-level object was selected, the new line gets added as a sibling. Here is how the new line looks like. The new line added is nothing but a skeleton that can be defined as required.

3

So, the first thing you see in a newly inserted line is a ‘Select an item’ drop down.

4

Given the fact that everything operation needs an object to be performed on, this is inevitable. Now as we already discussed item can be anything, a Test object, Statement, Utility Object or comment. The Test objects that are contained under a Container Object are displayed here. Therefore, according to our example, Agent Name, OK, Password is displayed in the list when a new step is to be added while clicking on or under the sub-level steps of the Login Dialog.

Object Repository:

If anything other than the items listed are required by the user there is an option to select the same from Object Repository. Now, this is the first time in our articles that we have encountered the word Object Repository. So, what is it really? When we try to put it simply, an Object Repository is what its name suggests. It a place or more like a database where all the Objects in a test are stored. This is what happens when the user chooses ‘Object Repository’ from the list.

5

So either from the list displayed or from Object repository an item can be selected. The next thing is to define the operation to be performed on the selected object. Click in the Operation column and a list of operations that can be performed on the selected object are displayed. This list is dependent on the type of object selected. For instance, a dialog object will have different methods available than when an Edit box is chosen.

Choose the desired operation

6

The next column is the Value. As we already know that this column is the argument to the operation to be performed on the selected item. On clicking in this column, the arguments are displayed as shown below:

7

If more than one argument is required to carry out the said operation, all the arguments will be displayed as multiple cells in the Value column.

The type operation on the ‘FlyFrom’ item needs a keyboard input. When the icon in this column is displayed the following dialog is displayed that helps the user to configure this value.

As you can see from the window above, the value to be entered in this field can either be a ‘Constant’ in which case the constant value can simply be typed in the text box and then followed by clicking the ‘OK’ button in the window.

Or it could be parameterized, which means it would be picked up from a location in the data sheet, a random number or an Environment variable. How to parameterize a value for an argument will be discussed in length later on.

8

In our example, I am writing “Test” in the constant field and clicking OK and here is how the line generated looks:

7

It should be noted that the ‘Documentation’ field gets auto-populated with the description pertaining to the operation performed on the item selected.

Conclusion:
So, that concludes the topic, ‘Adding a standard step to a test from the Keyword View’. We have discussed the various kinds of steps that can be added from the Keyword view and explored the adding of a Standard Step in detail.

We’ll have couple of more articles on QTP keyword view. In the coming articles, we will see how to add the other kinds of steps, adding conditional and loop statements and how the Keyword view can be used to modify/delete the test steps.

QTP Tutorial 2 : Introduction to QTP Keyword View

This article is going to give you an insight into the Keyword view of the QTP GUI. During this process we are going to get a quick introduction to Actions, Object Hierarchy and the basic columns in the keyword view.

Let’s start

There is a drop-down box at the top and it shows “Action 1”

Keyword-view-Action-1

What does this mean?

Introduction to Actions: Tests in QTP are recorded in terms of actions. Action is nothing but a set of statements performing a sequence of actions.  Most often an action is simply a logical unit of modularity. The calls to one or more actions can be defined as a QTP test.

For E.g.: Let’s assume that in an online web based email system, the user needs to login, compose and send email and then logout, it is recommended that each of these operations be divided into 3 different actions although all of them can be written under one action.

‘Test Email’ will have:

Action1
>Login
Action2
>Compose and send email
Action 3
>Logout
The Test is essentially:
Call to Action1; Call to Action 2; Call to Action 3

If written in one action, the lines of script would be large and difficult to manipulate and maintain. So the logical division is recommended. Also, as we move on further in our exploration about Actions we are going to understand how actions can be parameterized thus enabling easy repetition of a certain action as many times as desired.

So when you create a new QTP test it contains a call to one action, “Action 1”.

When we expand the drop down, it shows the Test Flow. For a test with multiple actions it shows the sequence in which each action is called thus making the name, “Test Flow” self explanatory. This drop-down not only displays the sequence of actions, it also provides the option for the user to select or go-to a particular action to view and/or Edit.

There is also a “Reusable Actions” Folder view. For now, let’s just say that reusable actions can be used by multiple tests and multiple times in the same test where it was created. We are going to discuss in detail how that can be achieved. Every action by default is reusable. This can be changed if need be.

Let’s take a little diversion here and talk a little bit about Object recognition hierarchy in QTP.

Object Hierarchy – If you have noticed in our example the Agent Name and Password are displayed under the item Login. A point to note here is that, QTP uses a tree hierarchy to store objects. In our case, the Agent Name and Password are the child objects to the container object Login which is the Dialog. Container objects are window, dialog box in a windows based environment and web page in a web based environment.

Here is an example, the login Dialog of the flights application:

QTP-login-Dialog-of-the-flights-application

The container here is the Login dialog and next level objects are Agent name, Password and the other buttons and images in the dialog. There are only 2 levels here. But there could be more levels, like browser.page.button in this case, browser is a container for page and page is a container for button.

Working with Keyword view:

I am going to use the test we recorded in the previous article. Opening the flights application. Entering the Agent Name and Password in the Login Page and Clicking on OK.

I am also going to add some function calls and statements to programmatically from Expert view and show you how they appear under the tabular form in the Keyword view.

This is the code I put in the expert view:

Dialog(“Login”).WinEdit(“Agent Name:”).Set “swati”

Dialog(“Login”).WinEdit(“Password:”).SetSecure “5112fd3c42beb7a58069b67cfdd9b7e7ad1fc69c”

Dialog(“Login”).WinButton(“OK”).Click

msgbox “text”

If x=0 Then

msgbox “text 2”

End If

Window(“Flight Reservation”).ActiveX(“MaskEdBox”).Type “010312”

Window(“Flight Reservation”).WinComboBox(“Fly From:”).Select “Denver”

Window(“Flight Reservation”).WinComboBox(“Fly To:”).Select “Frankfurt”
Lines 1 through 3 are the login operation. Line 4 is a function call to message box display operation. Then I added a dummy if statement just to show you how it appears in the keyword view. X is a dummy value as well. Since we are not going to run this test, let’s just use it theoretically. Lines 8 through 10 are entering the date of flight and to, from locations. This is used to understand how objects are grouped.

This code appears as follows in the Keyword view: QTP-keyword-view-screen-1024x728

As you can see there are 4 columns- Item, Operation, Value and Documentation. The table can be expanded or collapsed by clicking on the little arrow next to the action name.

Item: Each step is a sequence of events performed on an item. The item can be one of the following:

1. Test object (e.g.: Agent Name Edit box)
2. Utility Object: These are some objects reserved by QTP to be used in tests. E.g.: DataTable object. More coming up on         this later.
3. Statement: Any VB Script programmatic statement or even comments
4. Function call: like ‘msgbox’ call in our program
Operation: It shows the operation that is performed on the item. When this column is clicked for a particular item it lists all the available operations that can be performed on the object.

Operations-on-Objects-in-QTP

Value: This column can be considered as the argument of a statement displayed. In our example, the message box function call has a value “Text”. There can be multiple arguments to one statement in which case this column will be divided accordingly.

Documentation:  A read only column that translates a statement into easily understandable comments.

There are two other columns Assignment and Comment that can be added to the Keyword view table. To do so, the option to select is Tools->View Options and chooses the required columns from the list displayed.

1

Assignment: This column is not very widely used and what this does is assigns a value to or gets a value from a variable. [click on image to enlarge]

2

Comments: The tester can write anything under this column. It will be treated as comments in the expert view.

Conclusion:
Well, that sums up an interesting insight into the basic capabilities of the QTP keyword view. Actions are logical units of separation in a test. A test is therefore a series of function calls. When a new test is creation it contains one call to an action. By default all the actions are reusable. QTP follows a multi-level hierarchy to recognize objects. An object that contains a next level of objects is called a container. There can be more than one level of containers in a test.

In the next article we will talk about way we can use this view to Insert Steps. Modify them, Insert checkpoints, Breakpoints and how we can manage actions.

QTP Tutorial 1: Starting Testing using QTP / UFT

Quick Test Pro (QTP), later renamed Unified Functional Testing (UFT) is the industry leading automation product from Mercury Interactive. The other popular product from the Mercury Interactive stable was Win runner. However, due to better features offered by Quick Test Pro , Winrunner , which also has substantial features , was slowly and surely over taken over by QTP. In 2006 , Mercury Interactive was bought by HP (Hewlett Packard) and later QTP was renamed as UFT or Unified Functional testing. QTP or UFT is prominently used in Windows based environments . Here we shall try to understand how QTP/UFT works and how to use it for automating tests and how to write a framework so that maintenance becomes easier and volume of code becomes too big to maintain. However , we shall try to take topics one by one , in depth , so that we have no confusion left before progressing to the next topic. Begin… We assume that you have already installed UFT / QTP and have a license to use it . In this first tutorial we shall show how to start using QTP/UFT

  1. Start QTP / UFT by clicking the icon installed on the desktop or from program files
  2. After the license is   validated, the Add-in Manager Screen appears, which lets us select the add ins that are required. You may select all, but for the sake of performance, select only the relevant ones. For example if Oracle, Flex etc. are not there in your application do not select them.
  3. The start page appears once you click OK button
  4. Once the Start page appears, go to File – New test to create a new test
  5. The New Test window appears. Select “GUI Test”, give a name to the test, give a location to save it in and click the Create button.
  6. The workspace of the new Test appears as given below. Click the Action1 tab.
  7. You can also click the Action1 shown on the left side or Solution Explorer
  8. The Action workspace opens
  9. Click the Record button or the Record menu (F6)
  10. As the record button is clicked, the window given below comes up. Choose “Record and run test on any open browser” and click OK button. 11. QTP/UFT will start recording every single action that is performed on the chosen browser (you may choose other applications as well) and the following will get activated. The Stop button has to be clicked for stopping the recording 12.Perform the following tasks after opening Internet Explorer
  • Go to www.youtube.com
  • Once the site opens, click the left side link ‘Music’
  • Click the left side link Sports
  • Click the left side link Gaming
  • Close the window by pressing Alt + F4
  1. You will see that the actions have been captured in QTP/UFT editor. Now make the script in the editor just as given in the below picture. Once done, save the script.
  2. If there is an error in the script, when the Save button is clicked, an error will be shown as given below
  3. Click the Run button. The script runs and the test pass

QTP Tutorial 1. QTP Recording Process

In this article we will talk about the different recording modes, Object Spy and Object repositories in QTP.

Recording Modes in QTP:

Recording is the most commonly used method to create a test. The basic steps are typically recorded and the test later under goes improvements in order to suit the needs of the testing process.

QTP provides 3 modes of recording:

  1. Normal
  2. Low-level
  3. Analog

Though only the normal recording mode gets used most of the times, it is important to know the others too, as the knowledge about the same can come handy when the need arises for them.

Normal Recording mode- The default recording method is always the normal mode. In all our previous articles when we say record we meant the normal mode. So, as we know this method uses the model of Test Objects and Runtime objects to learn and act on the AUT.

Analog recording mode- records the exact mouse and key strokes that the user performs in relation to either the screen or AUT window.  The steps that are recorded using this method cannot be edited.

The way this usually gets represented in a code is:

Window/app.RunAnalog “Track1”

One scenario in which this type of recording can be used is when we are trying to capture a signature.

Low Level recording mode- This mode records the co-ordinates in the application where the operation is performed, irrespective of whether QTP recognizes the specific Object or Operation.

Some important points to note about these different modes are:

  1. In the middle of recording, we can switch to Analog/Low-level mode, finish the task required and go back to normal recording
  2. Analog and Low-level recording modes require more memory space than the normal mode.
  3. Mouse movements are not recorded in the low-level recording mode
  4. The switch to Analog mode is available only during recording and not during editing
  5. The test that is recorded in an analog mode will fail if it is run after changing the screen resolution.

The menu option to change the recording mode is:

Change-recording-mode-in-QTP

Object Spy:

Object Spy is an extremely helpful tool that QTP has to view the properties and operations of an object in the AUT. The prerequisite to using this tool is that the AUT has to be opened.The Object Spy can be accessed by using “Tools->Object Spy” or by directly clicking on the below

Object-Spy-in-QTP

It is also available from the Object repository and Object repository manager windows.

When Object Spy is launched, this is how its interface looks:

Object-Spy-launched-in-QTP

By clicking on the pointy hand you can point to any object whose properties you wish to examine. This is how it displays the properties:

Object-Spy-properties

As you can see, it shows all the properties of the object and the corresponding values. It shows the object hierarchy. There is also an ‘Operations’ tab which when clicked displays all the operations that can be performed on the test object:

Object-Spy-operations

The spy not only displays the properties, it also has a provision that lets the users add a certain object to the OR.

You can do that by clicking on the OR icon with a + in it.

Object Repository

In one of the previous articles we talked about how an OR is like a warehouse where all your objects are stored.

OR has the list of Objects that QTP learned during the record process and the class to which they belong. It stores the set of properties that uniquely identifies the Object (description) and also names the object for the sake of identification in our test, based on its most prominent feature.

The objects that are acted upon during record get automatically added to the OR. Alternately, the user can add additional objects on a need basis. This can be done directly from the OR window or from Object Spy.  (Ctrl+R or Resources->Object Repository or click on the icon.)

There are two kinds of repositories:

  1. Local
  2. Shared

Every time a test is created we have seen that a call to Action 1 is the only statement by default. We can add other actions and call them as needed. So, for every action QTP creates its own local repository by default.  It contains the objects that are related to that particular action.

Conversely, the user may decide to use a common repository for multiple actions in which case, this repository is to be associated with the actions and all of them can share the objects that it contains. This can be done using the “Object Repository manager’. The objects can be exported from a local repository into the shared one to maintain a single location for all the objects.  Also, a shared repository is read-only in the action level and any changes to it have to be made via ‘Object Repository manager’.

The repository to be used by an action has to be specified in the action properties.

How is it done practically is something we will look into using some examples later on.

Some of the important points to note here are:

  1. Even though there is a single shared repository for all actions every action will have its own local repository whether the test uses it or not. For example: For test 1 if there are Action 0, Action 1 and Action 2 and there is a shared repository ORShared, there will be local repositories OR0, OR1 and OR2 by default. However, if all the actions use one shared repository, local OR will be empty.
  2. If a local OR and Shared OR have an object with the same name, the action will consider the object in its local OR.
  3. There can be more than one Shared OR’s associated to the same action. If Shared OR1 and Shared OR2 have one object named OBJ1 each and if the action calls for OBJ1 then the order in which the shared ORs were associated will be considered. That means, if Shared OR1 was first associated then the OBJ1 from Shared OR1 will be taken into account.

It goes without saying that having a shared Object Repository is more efficient as it helps in easy maintenance and you can use one object description across multiple actions.

Here we covered some of the key concepts that will enable us to understand and create better QTP Tests. In my opinion information on Actions, Active screen and a rather impromptu but important password encoder tool are few more aspects we will have to cover before we move to more advanced topics.

%d bloggers like this: