Total Pageviews

Friday 27 January 2012

QTP Revision for freshers



VBScript is a subset of Visual Basic 4.0 language. It was developed by Microsoft to provide more processing power to Web pages. VBScript can be used to write both server side and client side scripting. (If you already know Visual Basic or Visual Basic for Applications (VBA)VB_Script_code, VBScript will be very familiar. Even if you do not know Visual Basic, once you learn VBScript, you are on your way to programming with the whole family of Visual Basic languages.)
Data types
VBScript supports only one data type called ‘Variant’. The variant data type is a special kind of data type that can contain different kinds of information. It is the default data type returned by all functions in VBScript. A variant behaves as a number when it is used in a numeric context and as a string when used in a string context. It is possible to make numbers behave as strings by enclosing them within quotes. 
Variables
A variable is a placeholder that refers to a memory location that stores program information that may change at run time. A variable is referred to by its name for accessing the value stored or to modify its value. 
Variable Declaration
Variables in VBScript can be declared in three ways: 
1.                   Dim Statement
2.                   Public Statement
3.                   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
You can also declare a variable implicitly by simply using its name in your script. That is not generally a good practice because you could misspell the variable name in one or more places, causing unexpected results when your script is run. For that reason, the Option Explicit statement is available to require explicit declaration of all variables. The Option Explicit statement should be the first statement in your script.
Note:
Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure.
Public statement variables are available to all procedures in all scripts.
Private statement variables are available only to the script in which they are declared. 
Naming Convention
There are standard rules for naming variables in VBScript. 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
Values are assigned to variables creating an expression as follows: the variable is on the left side of the expression and the value you want to assign to the variable is on the right. For example: 
B = 200

Scalar Variables and Array Variables

Much of the time, you only want to assign a single value to a variable you have declared. A variable containing a single value is a scalar variable. Other times, it is convenient to assign more than one related value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable. Array variables and scalar variables are declared in the same way, except that the declaration of an array variable uses parentheses ( ) following the variable name. In the following example, a single-dimension array containing 11 elements is declared: 
Dim A(10)
Although the number shown in the parentheses is 10, all arrays in VBScript are zero-based, so this array actually contains 11 elements. In a zero-based array, the number of array elements is always the number shown in parentheses plus one. This kind of array is called a fixed-size array.
Constants
A constant is a meaningful name that takes the place of a number or a string, and never changes. VBScript in itself has a number of defined intrinsic constants like vbOK, vbCancel, vbTrue, vbFalse and so on.
You create user-defined constants in VBScript using the Const statement. Using the Const statement, you can create string or numeric constants with meaningful names and assign them literal values. For example: 
Const MyString = "This is my string."Const MyAge = 49
Note that the string literal is enclosed in quotation marks (" "). Also note that constants are public by default.
Within procedures, constants are always private; their visibility can't be changed.
Next post we will deal with constructs and arrays.



Quick Test Professional (QTP) is an automated functional Graphical User Interface (GUI)
testing tool that allows the automation of user actions on a web or client based computer
application.

It is primarily used for functional regression test automation. QTP uses a scripting language built on top of VBScript to specify the test procedure, and to manipulate the objects and controls of the application under test.


Overview
QTP is a UI automation framework designed mainly for Windows and Web-based applications. It works by identifying the objects in the application UI or a web page and performing the desired operations on them (like mouse clicks or keyboard events); it can also be used to capture object properties like name or handler ID etc. One of the most important topics in QTP is Object Identification.QTP uses a scripting language built on top of VBScript to specify the test procedure, and to manipulate the objects and controls of the application under test.
Though QTP is usually used for “UI Based” Test Case Automation, it can easily handle “Non-UI” based Test Cases. (e.g. API (Certification testing), Database Testing, etc.)
Some of the key features of QTP are:

Plug-ins
Plug-ins are used to make recording more acceptable to a specific application, we use web plug-ins to automate test cases with respect to web applications. QTP has default plug-ins for ActiveX controls, web applications and VB objects. Plug-ins for other objects, such as Microsoft .NETobjects, are also available. Multimedia plug-ins and a plug-in for Windows Mobile are also available. In general, each QTP plug-in is available at an additional cost.
And QTP identifies the windows objects, even if we don’t select any plug-ins at the launching of the application .

License Models
Three types of licenses are available from HP:
1.
 Demo License : a 14-day demo license
2.
 Seat license : permanent seat license that is specific to the computer on which it is installed.
3.
 Floating (Concurrent): Floating allows a license to be shared between machines at any given point in time. (1 floating license allows QTP to be accessible from an entire lab’s worth of PCs but can only have 1 instance running at any given point in time).
Record and Playback
Initial development of automated tests with QTP is usually done by record-and-playback. A user’s actions are captured via Microsoft’s Component Object Model (COM). These are recorded into Actions, a kind of subroutine, as VBScript commands. All manipulated objects that QTP recognizes are also added to the object repository. Once recorded, the scripts are editable in either Keyword View or Expert View.
After clicking on the playback button all these actions will be played back. During playback, QTP attempts to identify and perform operations on the same objects, again using COM.

Checkpoints
Checkpoints are a feature used for verifying the application under test. One can add a checkpoint to check if a particular object, text or a bitmap is present in the automation run.
In short, checkpoints are used to verify that during the course of test execution, the actual application behavior or state is consistent with the expected application behavior or state.

There are 10 types of checkpoints available in QTP:
1. Standard Checkpoint — Checks the properties of an object.
2. Table Checkpoint — A Standard Checkpoint that checks the properties of a table.
3. Image Checkpoint — A Standard Checkpoint that checks the properties of an image.
4. Bitmap Checkpoint — Compares an area of the application under test pixel-for-pixel with the screen as seen at record-time.
5. Database Checkpoint — Used to automate back-end testing.
6. Text Checkpoint — Checks that a section of text is found between two other sections of text.
7. Text Area Checkpoint
8. Page Checkpoint — Checks the properties of a web page.
9. Accessibility Checkpoint — Checks the accessibility of an application.
10. XML Checkpoint
The VBScript Reporter.ReportEvent function also produces output very similar to that of a checkpoint, allowing the creation of custom checkpoints.

Recovery
Recovery is the name for exception handling in QTP, with the goal of enabling the tests to continue to run if an unexpected failure occurs. For instance if an application crash occurs and a message dialog appears, QTP can be instructed to attempt to restart the application and continue with the rest of the test cases from there

Output Value
This feature is used to store the run-time values/data that are displayed in the application into the run-time data table, so that we can use these run-time values in the script for further use.
Say we need the value which is dynamically created or processed by application for later use, we can go for output concept. We can follow the following example to understand. If the application produces an id for the person and we need that id, that can be solved using output concept, where we store value ‘id’ of that person in the data table and we can refer to that value later.

Data Table
The data table is a table primarily used to implement data-driven testing. It is implemented as a Microsoft Excel workbook that can be accessed from within QTP. There are two types of Data Tables available in QTP: the Global data sheet and the local data sheets. The Global data sheet is a single sheet which is accessible from every Action in a test. By default, each row of this sheet specifies the values to be used in an iteration of the entire test. The data table can be managed by other third party tools such as Grid Tools Datamaker, which offers features such as Data inheritance; substitution variables and version control.
There is also one local data sheet associated with each Action. As the Global data sheet specifies iterations of an entire test, these sheets are often used to set up iterations of a single Action. The data in these sheets can only be accessed from their associated Action. While it is possible to access a different Action’s local data sheet, it cannot be done from the Object Repository or from inside a checkpoint.

Virtual Objects
Complex objects may not be recognized properly by QTP. The Virtual Object concept was implemented to enable users to add some degree of support for these objects. If an object is not recorded out-of-the-box, an experienced user may be able to define that object as a personal virtual object and build a virtual object repository. Assuming that the required information can be extracted from the object, this allows the users to successfully record and playback against that object. In practice, this is not always possible.

Transactions
This feature can be used to calculate the time required to run a particular test or particular steps in the tests. Transactions are most often used in automated software performance testing, so they are infrequently used in QTP(Quick test Professional)

Results
QTP generates the result file for the test cases at the end of test in the form of XML tree. The result file provides detail regarding PASS and FAILS counts, error messages, and potentially supporting information that allows users to determine the underlying cause of a failure.

User Interface
QuickTest provides two main views of a script: Keyword View and Expert View. They are selected from tabs at the bottom of the QuickTest Professional window.

Keyword View
Keyword View is QTP’s default test procedure interface. It displays the automation steps of a test procedure as a descriptive tree of Actions and functions. The tree contains columns listing the Action or function name, any parameters, and comments. This mode is most useful for the beginners in operating with the tool. This view allows the user to select the objects either from the application or from the Object Repository and the user can select the methods to be performed on those objects. The script is automatically generated. Users can also set check points from keyword view.

Expert View
In Expert View, QTP allows display and editing of the a test’s source code. All test actions can be edited here except for the root Global action. Expert View acts as an IDE
 for the test. It includes most standard IDE features, such as breakpoints. This view is most suitable for the advanced users, enabling them to customize the test, such as by writing user-defined functions.
Languages
Supports VB Script. Supports classes but not supports polymorphism and inheritance.

What is QTP
QuickTest is a graphical interface record-playback automation tool. It is able to work with any web, java or windows client application. Quick Test enables you to test standard web objects and ActiveX controls. In addition to these environments, QuickTest Professional also enables you to test Java applets and applications and multimedia objects on Applications as well as standard Windows applications, Visual Basic 6 applications and .NET framework applications…

QTP is Mercury Interactive Functional Testing Tool. QTP stands for Quality Test Professional. Mercury QuickTest Professional: provides the industry's best solution for functional test and regression test automation - addressing every major software application and environment. This next-generation automated testing solution deploys the concept of Keyword-driven testing to radically simplify test creation and maintenance. Unique to QuickTest Professional's Keyword-driven approach, test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View.QuickTest Professional enables you to test standard Windows applications, Web objects, ActiveX controls, and Visual Basic applications. You can also acquire additional QuickTest add-ins for a number of special environments (such as Java, Oracle, SAP Solutions, .NET Windows and Web Forms, Siebel, PeopleSoft, Web services, and terminal emulator applications).
What's the basic concept of QTP?
QTP is based on two concept-
* Recording
* Playback
Which scripting language used by QTP? 
Basic scripting language we are using in QTP is VB scripting.
How many types of recording facility are available in QTP?
QTP provides three types of recording methods-
* Context Recording (
Normal)
* Analog Recording
* Low Level Recording
How many types of Parameters are available in QTP?
QTP provides three types of Parameter-
* Method Argument
* Data Driven
* Dynamic
What's the QTP testing process? 
QTP testing process consist of seven steps-
* Preparing to recoding
* Recording
* Enhancing your script
* Debugging
* Run
* Analyze
* Report Defects (more…)
How to Start recording using QTP? 
Choose Test > Record or click the Record button.
When the Record and Run Settings dialog box opens to do this;
1. In the Web tab, select Open the following browser when a record or run session begins.
2. In the Windows Applications tab, confirm that Record and run on these applications (opened on session start) is selected, and that there are no applications listed.


What's QuickTest Window? 

Before you begin creating tests, you should familiarize yourself with the main QuickTest window.
The QuickTest window contains the following key elements:

. Title bar—Displays the name of the currently open test.. Menu bar—Displays menus of QuickTest commands.. File toolbar—Contains buttons to assist you in managing your test.. Testing toolbar—Contains buttons to assist you in the testing process.
.
 Debug toolbar—Contains buttons to assist you in debugging tests.. Test pane—Contains the Keyword View and Expert View tabs.. Active Screen—Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.. Data Table—Assists you in parameterizing your test.. Debug Viewer pane—Assists you in debugging your test. The Debug Viewer pane contains the Watch Expressions, Variables, and Command tabs. (The Debug Viewer pane is not displayed when you open QuickTest for the first time. You can display the Debug Viewer by choosing View < Debug Viewer.). Status bar—Displays the status of the QuickTest application.
How does QTP identifes the object in the application 
QTP identifies the object in the application by LogicalName and Class.
For example :
The Edit box is identified by
Logical Name : PSOPTIONS_BSE_TIME20
Class: WebEdit
How many Add-ins comes by default with QTP? 
There are 3 Add-ins comes with QTP: (1) ActiveX (2) Visual Basic (3) Web
What are the views available in QTP
(1) Keyword View (2) Expert View
What is keyword view and Expert view in QTP? 
QuickTest's Keyword Driven approach, test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View. Advanced testers can view and edit their tests in the Expert View, which reveals the underlying industry-standard VBScript that QuickTest Professional automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.
What is Active Screen?
The Active Screen provides a snapshot of your application as it appeared when you performed a certain step during a recording session.
How many tabs are available in Debug Viewer Pane? 
The Debug Viewer pane contains three tabs to assist you in debugging your test or component—Watch Expressions, Variables, and Command. Watch Expressions The Watch Expressions tab enables you to view the current value of any variable or other VBScript expression. Variables The Variables tab enables you to view the current value of all variables that have been recognized up to the last step performed in the run session. Command The Command tab enables you to execute a line of script in order to set or modify the current value of a variable or VBScript object in your test or component. When you continue the run session, QuickTest uses the new value that was set in the command.
How many toolbars QTP has? 
QuickTest has 4 built-in toolbars: 1. The File toolbar 2. The Testing toolbar 3. The Debug toolbar 4. Action toolbar The Action toolbar is available in the Keyword View and contains options that enable you to view all actions in the test flow or to view the details of a selected action. The Action toolbar is not available for components.


What is object Repository ?Explain different types of Object Repositories?

QuickTest identifies objects in your application based on a set of test object properties. It stores the object data it learns in the object repository. You can save your objects either in a shared object repository or in action object repository. In shared object repository mode, you can use one object repository file for multiple tests or components. In object repository peraction mode, QuickTest automatically creates an object repository file for each action in your test. Object repository per-action mode is not available for components
What is Object Spy in QTP? 
Using the Object Spy, you can view the properties of any object in an open application. You use the Object Spy pointer to point to an object. The Object Spy displays the selected object's hierarchy tree and its properties and values in the Properties tab of the Object Spy dialog box


Explain different recording modes

QuickTest's normal recording mode records the objects in your application and the operations performed on them. This mode is the default and takes full advantage of QuickTest's test object model, recognizing the objects in your application regardless of their location on the screen.Analog Recording - enables you to record the exact mouse and keyboard operations you perform in relation to either the screen or the application window. In this recording mode, QuickTest records and tracks every movement of the mouse as you drag the mouse around a screen or window. This mode is useful for recording operations that cannot be recorded at the level of an object, for example, recording a signature produced by dragging the mouse.
Note: You cannot edit analog recording steps from within QuickTest. ?
Low-Level Recording - enables you to record on any object in your application, whether or not QuickTest recognizes the specific object or the specific operation. This mode records at the object level and records all run-time objects as Window or WinObject test objects. Use low-level recording for recording tests in an environment or on an object not recognized by QuickTest. You can also use low-level recording if the exact coordinates of the object are important for your test. Note: Steps recorded using low-level mode may not run correctly on all objects.
Explain the need to use analog recording in qtp?
This mode records exact mouse and Key Board operations you perform in relation to the screen /Application Window. This mode is useful for the operation which you can record at Object Level, such as drawing a picture, recording signature. The steps recorded using Analog Mode is saved in separated data file, Quick Tests add to your Test a Run Analog File statement that calls the recorded analog File. This file is stored with your action in which these Analog Steps are created. The Step recorded in Analog mode can not be edited within QTP.
What is the extension of script and object repository files? 
Object Repository : .tsr , Script : .mts, Excel : Default.xls
 
How to supress warnings from the "Test results page"?
From the Test results Viewer "Tools > Filters > Warnings"…must be "Unchecked". 
When we try to use test run option "Run from Step", the browser is not launching automatically why?
This is default behaviour


In how many ways we can add check points to an application using QTP.
We can add checkpoints while recording the application or we can add after recording is completed using Active screen (Note : To perform the second one The Active screen must be enabled while recording).




How to Run a Test using QTP?

1 Start QuickTest and open your test.If QuickTest is not already open, choose Start > Programs > QuickTest Professional > QuickTest Professional.. If the Welcome window opens, click Open Existing.. If QuickTest opens without displaying the Welcome window, choose File > Open or click the Open button.
In the Open Test dialog box, locate and select your test, then click Open.


2 Confirm that all images are saved to the test results.
QuickTest allows you to determine when to save images to the test results.
Choose Tools > Options and select the Run tab. In the Save step screen capture to test results option, select Always.Click OK to close the Options dialog box.


3 Start running your test.
Click Run or choose Test > Run. The Run dialog box opens.
Select New run results folder. Accept the default results folder name.
Click OK to close the Run dialog box.
How to Save your test using QTP? 
Select File > Save or click the Save button. The Save dialog box opens to the Tests folder.
Create a folder which you want to save to, select it, and click Open.
Type your test name in the File name field.
Confirm that Save Active Screen files is selected.
Click Save. Your test name is displayed in the title bar of the main QuickTest window.
How to open a new test using QTP?
1. If QuickTest is not currently open, choose Start > Programs > QuickTest Professional > QuickTest Professional. If the Welcome window opens, click Blank Test. Otherwise, choose File > New, or click the New button. A blank test opens.
2. . If QuickTest is already open, check which add-ins are loaded by selecting Help > About QuickTest Professional. If the Web Add-in is not loaded, you must exit and restart QuickTest. When the Add-in Manager opens, select the Web Add-in, and clear all other add-ins. Choose File > New, or click the New button. A blank test opens.
How to do Laod testing for web based Application?
1. Recording a scenerio in QTP of my web based application.
2. Make 100 copies of that scenerio and run the test (scenerio run for 100 times)
3. In that case, do the load of application on server.
4. The basic logic of running the copy 100 times is to create same scenerio as if 100 users were working
How to "Turn Off" QTP results after running a Script
Goto "Tools > Options > Run Tab" and Deselect "View results when run session ends". But this supresses only the result window, but a og will be created and can viewed manulaly which cannot be restricted from getting created.
Explain about the Test Fusion Report of QTP ? 
Once a tester has run a test, a TestFusion report displays all aspects of the test run: a high-level results overview, an expandable Tree View of the test specifying exactly where application failures occurred, the test data used, application screen shots for every step that highlight any discrepancies, and detailed explanations of each checkpoint pass and failure. By combining TestFusion reports with QuickTest Professional, you can share reports across an entire QA and development team.


What's Checkpoints for QTP

 A checkpoint verifies that expected information is displayed in your application while the test is running.
QuickTest Professional offers the following types of checkpoints: 



How to add a standard checkpoint in your test ?1. Start QuickTest and open your test.
In the Open Test dialog box, locate and select your test, then click Open.
2. Save the test as Checkpoint.
Select File > Save As. Save the test as Checkpoint
.3. Confirm that the Active Screen option is enabled.
If you do not see the Active Screen at the bottom of the QuickTest window, click the Active Screen button, or choose View > Active Screen.
4. Locate the page where you want to add a standard checkpoint.
5 Create a standard checkpoint.
In the Active Screen, right-click element in your application and choose Insert Standard Checkpoint.
6 Save the test.


How to add a page checkpoint to your test
The page checkpoint checks that the number of links and images in the page when you run your test is the same as when you recorded your test.
1 Locate the page where you want to add a page checkpoint.
2 Create a page checkpoint.
Right-click anywhere in the Active Screen, and choose Insert Standard Checkpoint. The Object Selection - Checkpoint Properties dialog box opens. Note that this dialog box may include different elements, depending on where you click in the Active Screen.
3 Save the test.
what is the use of Text output value in Qtp? 
Output values enable to view the values that the application talkes during run time.When paramaterised, the values change for each iteration.Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.
How to Creating an Output Value using QTP?1 Start QuickTest and open the Parameter test.
2 Save the test as Output.
3 Confirm that the Active Screen option is enabled.
4 Select the text you want to use as an output value.
5 Set the output value settings.
6 Modify the table checkpoint.
7 Save the test.
What's the difference between a checkpoint and output value?Checkpoint only checks for the specific attribute of an object in AUT while Output value can output those attributes value to a column in data table

Explain QTP Testing process


The QuickTest testing process consists of 6 main phases:
1. Create your test plan
Prior to automating there should be a detailed description of the test including the exact steps to follow, data to be input, and all items to be verified by the test. The verification information should include both data validations and existence or state verifications of objects in the application.2. Recording a session on your application
As you navigate through your application, QuickTest graphically displays each step you perform in the form of a collapsible icon-based test tree. A step is any user action that causes or makes a change in your site, such as clicking a link or image, or entering data in a form.


2. Enhancing your test
o Inserting checkpoints into your test lets you search for a specific value of a page, object or text string, which helps you identify whether or not your application is functioning correctly.
NOTE: Checkpoints can be added to a test as you record it or after the fact via the Active Screen. It is much easier and faster to add the checkpoints during the recording process.
o Broadening the scope of your test by replacing fixed values with parameters lets you check how your application performs the same operations with multiple sets of data.
o Adding logic and conditional statements to your test enables you to add sophisticated checks to your test.


3. Debugging your test
If changes were made to the script, you need to debug it to check that it operates smoothly and without interruption.


4. Running your test on a new version of your application
You run a test to check the behavior of your application. While running, QuickTest connects to your application and performs each step in your test.


5. Analyzing the test results
You examine the test results to pinpoint defects in your application.


6. Reporting defects
As you encounter failures in the application when analyzing test results, you will create defect reports in Defect Reporting Tool.


1. What are the Features & Benefits of Quick Test Pro (QTP 8.0)?

- Operates stand-alone, or integrated into Mercury Business Process Testing and Mercury Quality Center. Introduces next-generation zero-configuration Keyword Driven testing technology in Quick Test Professional 8.0 allowing for fast test creation, easier maintenance, and more powerful data-driving capability. Identifies objects with Unique Smart Object Recognition, even if they change from build to build, enabling reliable unattended script execution. Collapses test documentation and test creation to a single step with Auto-documentation technology. Enables thorough validation of applications through a full complement of checkpoints.


How many types of Actions are there in QTP?

There are three kinds of actions:
non-reusable action—an action that can be called only in the test with which it is stored, and can be called only once. reusable action—an action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.
external action—a reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.


What is the difference between Call to Action and Copy Action.?

Call to Action : The changes made in Call to Action , will be reflected in the orginal action( from where the script is called).But where as in Copy Action , the changes made in the script ,will not effect the original script(Action
Syntact for how to call one script from another? and Syntax to call one "Action" in another?
RunAction ActionName, [IterationMode , IterationRange , Parameters]
Here the actions becomes reusable on making this call to any Action.
IterationRange String Not always required. Indicates the rows for which action iterations will be performed. Valid only when the IterationMode is rngIterations. Enter the row range (i.e. "1-7
), or enter rngAll to run iterations on all rows.
If the action called by the RunAction statement includes an ExitAction statement, the RunAction statement can return the value of the ExitAction's RetVal argument.
Inserting a Call to Action is not Importing all columns in Datatable of globalsheet. Why?
Inserting a call to action will only Import the columns of the Action called 
How to execute a WinRunner Script in QTP?
(a) TSLTest.RunTest TestPath, TestSet [, Parameters ] –> Used in QTP 6.0 used for backward compatibility Parameters : The test set within Quality Center, in which test runs are stored. Note that this argument is relevant only when working with a test in a Quality Center project. When the test is not saved in Quality Center, this parameter is ignored.
e.g : TSLTest.RunTest "D:\test1
, ""
(b)TSLTest.RunTestEx TestPath, RunMinimized, CloseApp [, Parameters ] TSLTest.RunTestEx "C:\WinRunner\Tests\basic_flight", TRUE, FALSE, "MyValue" CloseApp : Indicates whether to close the WinRunner application when the WinRunner test run ends. Parameters : Up to 15 WinRunner function argument
Why divide a test into three action calls?
When you create a new test, it contains a call to one action. By dividing your tests into calls to multiple actions, you can design more modular and efficient tests.


What is parameter?

A parameter is a variable that is assigned a value from an external data source or generator. If you wish to parameterize the same value in several steps in your test or component, you may want to consider using the Data Driver rather than adding parameters manually.
How many ways we can parameterize data in QTP ?
There are four types of parameters:

Test, action or component parameters enable you to use values passed from your test or component, or values from other actions in your test.
Data Table parameters enable you to create a data-driven test (or action) that runs several times using the data you supply. In each repetition, or iteration, QuickTest uses a different value from the Data Table.
Environment variable parameters enable you to use variable values from other sources during the run session. These may be values you supply, or values that QuickTest generates for you based on conditions and options you choose.
Random number parameters enable you to insert random numbers as values in your test or component. For example, to check how your application handles small and large ticket orders, you can have QuickTest generate a random number and insert it in a number of tickets edit field.
How Does Run time data (Parameterization) is handled in QTP?
You can then enter test data into the Data Table, an integrated spreadsheet with the full functionality of Excel, to manipulate data sets and create multiple test iterations, without programming, to expand test case coverage. Data can be typed in or imported from databases, spreadsheets, or text files.

How to Defining a Data Table Parameter for QTP?
1 Start QuickTest and open the Checkpoint test.
2 Save the test as Parameter.
3 Confirm that the Active Screen option is enabled.
4 Confirm that the Data Table option is enabled.
5 Select the text to parameterize.
6 Set the parameterization properties.
How to add a runtime parameter to a datasheet?
DataTable.LocalSheet
The following example uses the LocalSheet property to return the local sheet of the run-time Data Table in order to add a parameter (column) to it.
MyParam=DataTable.LocalSheet.AddParameter("Time", "5:45
)


Introduction:

This document demonstrates the usage of Descriptive programming in QTP 8.20. It also discusses situations where Descriptive programming can be used. Using Descriptive Programming automation scripts can be created even if the application has not been developed.

Descriptive Programming:

Whenever QTP records any action on any object of an application, it adds some description on how to recognize that object to a repository of objects called object repository. QTP cannot take action on an object until unless its object description is in the Object Repository. But descriptive programming provides a way to perform action on objects which are not in Object repository

Object Identification:


To identify an object during the play back of the scripts QTP stores some properties which helps QTP to uniquely identify the object on a page. Below screen shots shows an example Object repository:






***ABOVE IMG

Now to recognize a radio button on a page QTP had added 2 properties the name of the radio button and the html tag for it. The name the left tree view is the logical name given by QTP for the object. This can be changed as per the convenience of the person writing the test case. QTP only allows UNIQUE logical name under same level of hierarchy. As we see in the snapshot the two objects in Browser->Page node are "WebTable" and "testPath", they cannot have the same logical name. But an object under some other node can have the same name. Now with the current repository that we have, we can only write operation on objects which are in the repository. Some of the example operations are given below

Browser("Browser").Page("Page").WebRadioGroup ("testPath").Select "2"

cellData = Browser("Browser").Page("Page").WebTable ("WebTable").GetCellData (1,1)

Browser("Example2").Page("Page").WebEdit("testPath").Set "Test text"

When and Why to use Descriptive programming?


Below are some of the situations when Descriptive Programming can be considered useful:



·                     The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. "Logout <<UserName>>".

·                     When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object.

·                     When you don't want to use object repository at all. Well the first question would be why not Object repository? Consider the following scenario which would help understand why not Object repository

Scenario 1: Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing

Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be "Cancel", "Back" and "Next". Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page.



·                     Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.

·                     When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.
How to use Descriptive programming?
There are two ways in which descriptive programming can be used




·                     By giving the description in form of the string arguments.
·                     By creating properties collection object for the description.



.      Qtp is automation tool actually first tool  (before QTP) AQT (Actra Quick Test) are used for test the application
2.      Later mercury had took the Qtp and they started with  - Here I would like to share the version history of Quick Test Professional .
1998 -> Astra QT
2000 -> QTP 5.0
2001 -> QTP 5.5
2002 -> QTP 6.0
2003 -> QTP 6.5
2004 -> QTP 8.0
2005 -> QTP 8.2
2006 Feb -> QTP 9.0
2007 Jan -> QTP 9.1
2007 Feb -> QTP 9.2
2008 Jan -> QTP 9.5
2009 Feb -> QTP 10
3.      Now recently 11 version are released

4.      These qtp versions are very good effective to test the any application Before QTP all company’s  were used by Win runner tool (It’s also good tool) its for GUI test and next test for web application by AQT

5.      The qtp is for both of Win Runner and AQT

Win Runner   -}
AQT                 - }         QTP

6.      The qtp is work with GUI and Web based applications
7.      QTP has support scripting language –  a. VB script  b. Microsoft shall script  c. Java Script  d. XML
8.      Variable:  The name of the data type for VBscript is called variable
9.      Variables are using anywhere in scripting
EG : Dim a,b
A=10
B=”Rama”
Dim c
C=20

For example in the qtp script we can write Optional Explicit.    * It is in the first line of script.
VB script is not a case sencitive
EG: Dim Emp No
Emp no
Print emp no

10.  Operators: operators are like mathematical operators  , In  script we use
\   - Back slash

Mod  - 10 mod 4 =2

^    - 5^3 = 1

11.  VB script is not object oriented language – it is a object based language
12.  The object contains attributes , attributes are 3 types

1. Properties:   It is explain the project any thing (In QTP the objects can be classified in to two types. They are Test Objects and Run Time Objects. Run time objects are the real objects present in the application. Test objects are the references for the runtime objects created by the QTP while recording. Later these test objects are used by the tool to identify the runtime objects. Both these have some methods and properties)

2. Methods   : It is test the functionality of our project

3. events       : Clicks

13.   What is difference between dialog box and window box?
If it is contains menu bar called widow box
If it is not contains menu bar called dialog box

14.   Script for xyz dialog box?
Window(“xyz”).Win Edit(“Emp Id”).Set”100”
Window(“xyz”).Win Button(“Search”).Click

Window  is logical name of object
 (“xyz”) is class name of object

Classname + Logical name = Physical description
   

Eg: Flight Application
Dailog(“Login”).WinEdit(“AgentName:”).Set “RK”
Dailog(“Login”).WinEdit(“Password:”).Set “Mercury”
Dailog(“Login”).WinButton(“Ok”).Click


Qtp has internal component is object repository
QTP has never go directly to any application it used object repository

Click on resources -> Click object Repository -> Test Object-> Add objects to tool  (ICON)

-          In the qtp some keywords of run application
-          F11 is step by step run
-          F5 is Run application

15.   Object Spy :  It is very important concept
Click on Object spy icon -> Click on show hand -> Click on any where in application
It shows all properties of application fields

The object spy is used for when user want to know all the properties of any values then use spy hand key

-          Click on flight application then enter all the data in that field and say insert order
-          If any script delete in qtp but do not delete it , just put single line (‘) then it is disable and do not run……………
Control+M is for comment multi lines (Just copy all lines and say Control+M)
If uncomment Control+shift+M

No comments:

Post a Comment