How to write better QTP scripts

This post refers to a thought provoking question which was asked on Testing Tools forum. In this query jp@QTP is looking for ways to optimize QTP scripts for best performance. Everyone knows we use automated testing tools to optimize our testing process. Unless you make full use of the capability of the tool and unless a tool is used sensibly and with proper planning, it would not yield any results. Just record-and-playback is never the solution for any project. You need to go deep inside to understand the intricacies of any tool. Any software testing tool is only as good as the test engineer using it. On those thoughts, I feel this was one of the best questions asked in the forums of late.
Well, here are some of my tips and tricks to optimize the QTP scripts:

* Launch QTP using a .vbs file and not the QTP desktop icon. You will notice a substantial increase in speed. [Refer the earlier post on How to open QTP using vbs file? ,you just need the 1st point of that post]
* For large tests, always define variables, function in an external .vbs file and not inside a reusable action. Attach these files with your test scripts. If you define a variable or a function in an action, on every iteration of your test run, memory(RAM) will be allocated to those variables/functions and would not be released. Now as your script starts consuming more and more RAM, your System Under Test (SUT) will tend to become slower.
* While running, QTP consumes a lot of memory by itself. It is always advisable to have lots of available RAM( much more than what is recommended by HP) and good processor speed on a system where you intend to install QTP. When you have tests (and hence QTP) running for a prolonged period if time, there are chances of memory leaks. To avoid memory leakage always restart QTP at some intervals of time. Using AOM you can automate this process. [If you want to go into details of effect of RAM on speed of computer read the post on RAM, Memory Usage thoroughly]
* Avoid using hard coded wait(x) statement. Wait statement waits for full x seconds, even if the event has already occurred. Instead use .sync or exist statement. While using exist statement always have a value inside it.

For ex: .Exist(10) Here QTP will wait max till 10 seconds and if it finds the object at (say) 3 secs , it will resume the execution immediately thereby saving your precious time. On the other hand if you leave the parenthesis blank, QTP would wait for object synchronization timeout you have mentioned under File > Test Settings > Run Tab.

* Make full use of what HP-QTP has provided you in the tool IDE. Use “Automatically Generate “With” statements after recording” option present under Tools > Options > General Tab. This will not only make your code look neater but also make your scripts perform better.
* Make your own judgement whether you want to go for Descriptive Programming or Object Repository or mixed approach. Each approach has it own pros and cons that in turn is related to QTP performance.
* Unless absolutely required, uncheck the options “Save still image capture to results” and “Save movie to results” present under Tools > Options > Run tab. These options definitely have some bearing on QTP run time performance.
* Make the Run Mode as “fast”. This setting is present under Tool > Options > Run tab. Note: If you intend to run your scripts from QC no need to worry about this option, as the scripts WILL run in fast mode whether you want or not.
* If you are new to automation or QTP. Read this beginner article on Automation Object Model (AOM). AOM simplifies many aspects of QTP scripting. It can help you in controlling QTP from an external file.
* Make use of relative paths while calling reusable actions in your script. Using relative path would make your script portable and easy to manage. I will cover in detail how to’s and why’s of using relative paths in my next post.
Read On 0 comments

Tips on QTP

1) How to add a constant number in a datatable?
This is more to do with MS excel then QTP!! but useful to know because at times it becomes frustrating to the novices.
Just append ' to the number
Ex: if you wish to enter 1234567 in datatable then write it as '1234567

2) How can i check if a parameter exists in DataTable or not?
The best way would be to use the below code:
on error resume next
val=DataTable("ParamName",dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if

3) How can i check if a checkpoint passes or not?
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
if chk_PassFail then
MsgBox "Check Point passed"
else MsgBox "Check Point failed"
end if

4) My test fails due to checkpoint failing, Can i validate a checkpoint without my test failing due to checpoint failure?
Reporter.Filter = rfDisableAll 'Disables all the reporting stuff
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
Reporter.Filter = rfEnableAll 'Enable all the reporting stuff
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if

5) What is the difference between an Action and a function?
Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a object repository associated with it while a function can't. A function is just lines of code with some/none parameters and a single return value while an action can have more than one output parameters.

6) Where to use function or action?
Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action. Code specific to QTP can also be put into an function using DP. Decision of using function/action depends on what any one would be comfortable using in a given situation.

7) When to use a Recovery Scenario and when to us on error resume next?
Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won't occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper", as this error is caused by printer device driver. "On error resume next" should be used when you know if an error is expected and dont want to raise it, you may want to have different actions depending upon the error that occurred. Use err.number & err.description to get more details about the error.

8) How to use environment variable?
A simple defintion could be... it is a variable which can be used across the reusable actions and is not limited to one reusable action.
There are two types of environment variables:
1. User-defined
2. Built-in
We can retrieve the value of any environment variable. But we can set the value of only user-defined environment variables.

To set the value of a user-defined environment variable:
Environment (VariableName) = NewValue

To retrieve the value of a loaded environment variable:
CurrValue = Environment (VariableName)

Example
The following example creates a new internal user-defined variable named MyVariable with a value of 10, and then retrieves the variable value and stores it in the MyValue variable.

Environment.Value("MyVariable")=10
MyValue=Environment.Value("MyVariable")
9) What are the files and subfolders of a QuickTest Professional test?
The files and folders hold binary and text data that are required for the test to run successfully.
The following table provides a description, the type, and comments regarding the files that make up a QuickTest Professional test.

File Name

Description

Type

Comments Regarding File

Test.tsp

Test settings

Binary

Do not edit

Default.xls

Data table parameters

Excel similar

Can be edited using Excel

Parameters.mtr

Parameterization information

Binary

Do not edit

Action

Action folder (See other table)



Default.cfg

Load test configuration file

Text

Do not edit

Default.prm

Load test configuration file

Text

Do not edit

Default.usp

Load test configuration file

Text

Do not edit

.usr

Load test configuration file

Text

Do not edit

Thick_usr.dat

Load test configuration file

Text

Do not edit

Thin_usr.dat

Load test configuration file

Text

Do not edit
Files within Action folder:

File Name

Description

Type

Comments Regarding File

Script.mts

Action script

Text

Edit text preceding the @@ sign only

Resource.mtr

Object Repository

Binary

Do not edit

Snapshots

Active screen files

Folder

Do not edit
There are few more files extensions like
.MTB Batch File
.LCK Locked
10) How to rename a checkpoint (QTP 9.0)?
Example:
Window("Notepad").WinEditor("Edit").Check CheckPoint("Edit")
In the above example, the user would like to change the name of the CheckPoint object from "Edit" to something more meaningful.
Note:
This functionality is new to QuickTest Professional 9.0.This is not available for QTP 8.2 and below.
1. Right-click on the Checkpoint step in the Keyword View or on the Checkpoint object in Expert View.
2. Select "Checkpoint Properties" from the pop-up menu.
3. In the Name field, enter the new checkpoint name.
4. Click . The name of the checkpoint object will be updated within the script.
Example:
Window("Notepad").WinEditor("Edit").Check CheckPoint("NewCheckPointName")
Note:
You must use the QuickTest Professional user interface to change the name of the checkpoint. If you manually change the name of the checkpoint in the script, QuickTest Professional will generate an error during replay. The error message will be similar to the following:

"The "" CheckPoint object was not found in the Object Repository. Check the Object Repository to confirm that the object exists or to find the correct name for the object."
The CheckPoint object is not a visible object within the object repository, so if you manually modify the name, you may need to recreate the checkpoint to resolve the error.

11) Does QuickTest Professional support Internet Explorer 7.0?
QuickTest Professional 9.1
QuickTest Professional 9.1 supports Microsoft Internet Explorer 7.0 Beta 3. Internet Explorer version 7.0 is now certified to work and to be tested with QuickTest Professional version 9.1.
QuickTest Professional 9.0
QuickTest Professional 9.0 supports Internet Explorer 7.0 Beta 2.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not include support for Internet Explorer 7.0.
Does QuickTest Professional support Firefox?
QuickTest Professional 9.1 and 9.2
QuickTest Professional 9.1 provides replay support for Mozilla Firefox 1.5 and Mozilla Firefox 2.0 Alpha 3 (Alpha-level support for Bon Echo 2.0a3).
Notes:
QuickTest Professional 9.1 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 9.0
QuickTest Professional 9.0 provides replay support for Mozilla FireFox 1.5.
Notes:
QuickTest Professional 9.0 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not have support for Firefox.


12) Problem
After Quick Test Professional is started, Windows Media will not start. It returns the error message "wmplayer.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created."
If you start Window's Media Player first, it will continue to work normally after starting QuickTest Professional.
Solution:
Include the Windows Media Player's executable in the NoBBTApps section of the mic.ini file
1. Close QuickTest Professional.
2. Go to \bin\mic.ini.
3. Include wmplayer.exe in the NoBBTApps section of mic.ini file.
Example:
[NoBBTApps]
wmplayer.exe=rek
4. Save the mic.ini file and restart QuickTest Professional.
13) What is the lservrc file in QTP?

The lservrc file contains the license codes that have been installed
The lservrc file contains the license codes that have been installed. Whenever a new license is created, the license code is automatically added to this file. The lservrc file is a text file, with no extension.
File Location:

1) For a Concurrent (Floating) license installation:
"#server installation directory#\#language#"
Example:
C:\Program Files\XYZ Technologies\ABC Server\English\lservrc
2) For a Seat (Stand-alone) license installation:
#AQT/QTP installation directory#\bin"
Example:
C:\Program Files\Mercury Interactive\QuickTest Professional\Bin\lservrc
14) What to do if you are not able to run QTP from quality center?
This is for especially for newbies with QTP.
Check that you have selected Allow other mercury products to run tests and components from Tools--> Options--> Run Tab.

15) Does QuickTest Professional support Macintosh operating systems?
No, QTP is not expected to run on this OS.
Read On 0 comments

Technical Interview Questions on QTP

1. What is Test Frame Work?
2. How comfortable are you in VB Scripting?
3. What is Description Object?
4. What are SetToProperty, SetRoProperty, GetToProperty scripting?
5. What is the difference between version 6.5 and 8.2?
6. What is the difference between Normal mode and Fast mode?
7. How do you invoke the application through QTP?
8. How do you close the Task Manager through QTP?
9. How will you load the object during run time?
10. How will you handle the situation when object is not captured during record?
11. What is test object?
12. How QTP recognizes the objects stored in object repository
13. What is post recovery scenario?
14. What is reusable action and how the same can be implemented (process)
15. How will u integrate oracle with QTP
16. How QTP integrate with application
17. What is object repository?
18. What are all the fields present in object repository?
19. What is smart identification?
20. What are the mandatory properties for a text box (scenario?)
21. What is Checkpoint?
22. What is object?
23. What are the properties of object?
24. What is Action?
25. What will be there in Keyword view and Expert View?
26. What is regular expression how will u implement it
27. Where the checkpoints are stored
28. What is database checkpoint, how will u parameterize the database from separate data table
29. How will u handle application crash using recovery scenario manager (Step By Step Process)
30. What is Virtual Object?
31. What is the difference between calling a function and reusing an action?
32. How QTP support all types of applications (Platforms)
33. What is the difference between application testing and product testing?
34. What is throw object?
35. What is Run-time Data?
36. How will you enhance the script?
37. Can objects recogonised without repository?
38. Where did u automate in ur project
39. Any challenge that faced in ur project
40. Batch test,run action
41. Purpose of automation
42. Diff ways of parameterising
43. Error handled other than recovery scenario manager
44. Diff betw WR and QTP
45. What kind of errors can b handled?
46. How you used DDT in QTP?
47. Difference between keyword driven test and DDT?
48. How did you use regular expression in QTP and also in Win Runner?
49. How do you learn the object in QTP?
50. How will you handle custom object in QTP?
51. Differences in QTP and Win Runner.
52. Give us the Definition for Integration Testing, Regression Testing System Testing
53. How will you report the bug and explain the defect tracking Sheet you handled?
54. What In-string function will do?
55. What is L-trim function will do?
56. WinRunner and QTP difference?
57. In website, protocol has been changed http: to https what you will do? Tell me your Approach?
58. What Framework you are following?
59. How to load the object repository at run time?
60. How much strong on VB and C?
61. How to compare the 2 strings?
62. What is the Silent mode in WinRunner?
63. Have you worked with Quality Center?
64. Have you used Test Director?
65. What is QTP Test Frame work?
66. Definitions for Keyword view and Tree View?
67. What is Smart Identification?
68. What is Object Repository?
69. What is your experience level in QTP?
70. What is your Role and Responsibilities In QTP with your current organisation?
71. Explain the following:
Import and Export of files.
Random testing of 500 test cases.
Invoking of application
Opening notepad in QTP &Writing of Test Result in Notepad.
Merging of Two Repositories
Datafile / Verification of data file when file is not available in local system.
Business process component / Types and usage.
Opening of notepad in QTP to write and execute the coding.
How to find local host name using QTP
How to handle exception when data table is not available in local host system or Path is not correct (Explain Statement with example)
Runtime dynamic settings.
Script generated after applying database check point.
Script generated at the time of setting runtime property.
Types of exception handling and script for that.
Scripting
Read On 1 comments

QTP FAQ-1

QTP interview questions

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 to handle the exceptions using recovery scenario manager in QTP? - There are 4 trigger events during which a recovery scenario should be activated. A pop up window appears in an opened application during the test run: A property of an object changes its state or value, A step in the test does not run successfully, An open application fails during the test run, These triggers are considered as exceptions.You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps: 1. Triggered Events 2. Recovery steps 3. Post Recovery Test-Run

What is the use of Text output value in QTP? - Output values enable to view the values that the application talks during run time. When parameterized, 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 use the Object spy in QTP 8.0 version? - There are two ways to Spy the objects in QTP: 1) Thru file toolbar, In the File Toolbar click on the last toolbar button (an icon showing a person with hat). 2) True Object repository Dialog, In Object repository dialog click on the button object spy. In the Object spy Dialog click on the button showing hand symbol. The pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object if at all the object is not visible. or window is minimized then, hold the Ctrl button and activate the required window to and release the Ctrl button.

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.

What is keyword view and Expert view in QTP? - Quick Test’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 Quick Test Professional automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.

Explain about the Test Fusion Report of QTP? - Once a tester has run a test, a Test Fusion 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 Test Fusion reports with Quick Test Professional, you can share reports across an entire QA and development team.

Which environments does QTP support? - Quick Test Professional supports functional testing of all enterprise environments, including Windows, Web,..NET, Java/J2EE, SAP, Siebel, Oracle, PeopleSoft, Visual Basic, ActiveX, mainframe terminal emulators, and Web services.

What is QTP? - Quick Test 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, Quick Test 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

Explain QTP Testing process? - Quick Test testing process consists of 6 main phases:
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.
Recording a session on your application - As you navigate through your application, Quick Test 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.
Enhancing your test - 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. 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. Adding logic and conditional statements to your test enables you to add sophisticated checks to your test.
Debugging your test - If changes were made to the script, you need to debug it to check that it operates smoothly and without interruption.
Running your test on a new version of your application - You run a test to check the behavior of your application. While running, Quick Test connects to your application and performs each step in your test.
Analyzing the test results - You examine the test results to pinpoint defects in your application.
Reporting defects - As you encounter failures in the application when analyzing test results, you will create defect reports in Defect Reporting Tool.

Explain the QTP Tool interface. - It contains the following key elements: Title bar, displaying the name of the currently open test, Menu bar, displaying menus of Quick Test commands, File toolbar, containing buttons to assist you in managing tests, Test toolbar, containing buttons used while creating and maintaining tests, Debug toolbar, containing buttons used while debugging tests. Note: The Debug toolbar is not displayed when you open Quick Test for the first time. You can display the Debug toolbar by choosing View — Toolbars — Debug. Action toolbar, containing buttons and a list of actions, enabling you to view the details of an individual action or the entire test flow. Note: The Action toolbar is not displayed when you open Quick Test for the first time. You can display the Action toolbar by choosing View — Toolbars — Action. If you insert a reusable or external action in a test, the Action toolbar is displayed automatically. Test pane, containing two tabs to view your test-the Tree View and the Expert View ,Test Details pane, containing the Active Screen. Data Table, containing two tabs, Global and Action, to assist you in parameterizing your test. Debug Viewer pane, containing three tabs to assist you in debugging your test-Watch Expressions, Variables, and Command. (The Debug Viewer pane can be opened only when a test run pauses at a breakpoint.) Status bar, displaying the status of the test

How does QTP recognize Objects in AUT? - Quick Test stores the definitions for application objects in a file called the Object Repository. As you record your test, Quick Test will add an entry for each item you interact with. Each Object Repository entry will be identified by a logical name (determined automatically by Quick Test), and will contain a set of properties (type, name, etc) that uniquely identify each object. Each line in the Quick Test script will contain a reference to the object that you interacted with, a call to the appropriate method (set, click, check) and any parameters for that method (such as the value for a call to the set method). The references to objects in the script will all be identified by the logical name, rather than any physical, descriptive properties.

What are the types of Object Repositories in QTP? - Quick Test has two types of object repositories for storing object information: shared object repositories and action object repositories. You can choose which type of object repository you want to use as the default type for new tests, and you can change the default as necessary for each new test. The object repository per-action mode is the default setting. In this mode, Quick Test automatically creates an object repository file for each action in your test so that you can create and run tests without creating, choosing, or modifying object repository files. However, if you do modify values in an action object repository, your changes do not have any effect on other actions. Therefore, if the same test object exists in more than one action and you modify an object’s property values in one action, you may need to make the same change in every action (and any test) containing the object.

Explain the check points in QTP? - A checkpoint verifies that expected information is displayed in an Application while the test is running. You can add eight types of checkpoints to your test for standard web objects using QTP. A page checkpoint checks the characteristics of an Application. A text checkpoint checks that a text string is displayed in the appropriate place on an Application. An object checkpoint (Standard) checks the values of an object on an Application. An image checkpoint checks the values of an image on an Application. A table checkpoint checks information within a table on a Application. An Accessibilityy checkpoint checks the web page for Section 508 compliance. An XML checkpoint checks the contents of individual XML data files or XML documents that are part of your Web application. A database checkpoint checks the contents of databases accessed by your web site
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 does QTP identify objects in the application? - QTP identifies the object in the application by Logical Name and Class.

What is Parameterizing Tests? - When you test your application, you may want to check how it performs the same operations with multiple sets of data. For example, suppose you want to check how your application responds to ten separate sets of data. You could record ten separate tests, each with its own set of data. Alternatively, you can create a parameterized test that runs ten times: each time the test runs, it uses a different set of data.

What is test object model in QTP? - The test object model is a large set of object types or classes that Quick Test uses to represent the objects in your application. Each test object class has a list of properties that can uniquely identify objects of that class and a set of relevant methods that Quick Test can record for it. A test object is an object that Quick Test creates in the test or component to represent the actual object in your application. Quick Test stores information about the object that will help it identify and check the object during the run session.

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.

What is the Diff between Image check-point and Bit map Check point? - Image checkpoints enable you to check the properties of a Web image. You can check an area of a Web page or application as a bitmap. While creating a test or component, you specify the area you want to check by selecting an object. You can check an entire object or any area within an object. Quick Test captures the specified object as a bitmap, and inserts a checkpoint in the test or component. You can also choose to save only the selected area of the object with your test or component in order to save disk Space. For example, suppose you have a Web site that can display a map of a city the user specifies. The map has control keys for zooming. You can record the new map that is displayed after one click on the control key that zooms in the map. Using the bitmap checkpoint, you can check that the map zooms in correctly. You can create bitmap checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded). Note: The results of bitmap checkpoints may be affected by factors such as operating system, screen resolution, and color settings.

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, Quick Test 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 Quick Test 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 Quick Test generate a random number and insert it in a number of tickets edit field.

How do u do batch testing in WR & is it possible to do in QTP, if so explain? - Batch Testing in WR is nothing but running the whole test set by selecting Run Test set from the Execution Grid. The same is possible with QTP also. If our test cases are automated then by selecting Run Test set all the test scripts can be executed. In this process the Scripts get executed one by one by keeping all the remaining scripts in Waiting mode.

If I give some thousand tests to execute in 2 days what do u do? - Adhoc testing is done. It Covers the least basic functionalities to verify that the system is working fine.

What does it mean when a check point is in red color? what do u do? - A red color indicates failure. Here we analyze the cause for failure whether it is a Script Issue or Environment Issue or a Application issue.

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.

What is the file extension of the code file & object repository file in QTP? - Code file extension is.vbs and object repository is.tsr

Explain the concept of object repository & how QTP recognizes objects? - Object Repository: displays a tree of all objects in the current component or in the current action or entire test (depending on the object repository mode you selected). We can view or modify the test object description of any test object in the repository or to add new objects to the repository. Quicktest learns the default property values and determines in which test object class it fits. If it is not enough it adds assistive properties, one by one to the description until it has compiled the unique description. If no assistive properties are available, then it adds a special Ordinal identifier such as objects location on the page or in the source code.

What are the properties you would use for identifying a browser & page when using descriptive programming?
Name would be another property apart from title that we can use.
Give me an example where you have used a COM interface in your QTP project? - com interface appears in the scenario of front end and back end. for eg:if you r using oracle as back end and front end as VB or any language then for better compatibility we will go for an interface. of which COM will be one among those interfaces. Create object creates handle to the instance of the specified object so that we program can use the methods on the specified object. It is used for implementing Automation(as defined by Microsoft).

Explain in brief about the QTP Automation Object Model. - Essentially all configuration and run functionality provided via the Quick Test interface is in some way represented in the Quick Test automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in Quick Test have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods. You can use the objects, methods, and properties exposed by the Quick Test automation object model, along with standard programming elements such as loops and conditional statements to design your program.
Read On 0 comments

QTP FAQ - Part I

Data Table
Two Types of data tables
Global data sheet: Accessible to all the actions
Local data sheet: Accessible to the associated action only
Usage:
DataTable("Column Name",dtGlobalSheet) for Global data sheet
DataTable("Column Name",dtLocalSheet) for Local data sheet
If we change any thing in the Data Table at Run-Time the data is changed only in the run-time data table. The run-time data table is accessible only through then test result. The run-time data table can also be exported using DataTable.Export or DataTable.ExportSheet
How can i save the changes to my DataTable in the test itself?
Well QTP does not allow anything for saving the run time changes to the actual data sheet. The only work around is to share the spreadsheet and then access it using the Excel COM Api's.
How can i check if a parameter exists in DataTable or not?
The best way would be to use the below code:
on error resume next
val=DataTable("ParamName",dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else 'Parameter exists
end if
SMART Identification
Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of the object. A very generic example as per the QTP manual would be, A photograph of a 8 year old girl and boy and QTP records identification properties of that girl when she was 8, now when both are 10 years old then QTP would not be able to recognize the girl. But there is something that is still the same, that is there is only one girl in the photograph. So it kind of PI (Programmed intelligence) not AI.
When should i use SMART Identification?
Something that people don't think about too much. But the thing is that you should disable SI while creating your test cases. So that you are able to recognize the objects that are dynamic or inconsistent in their properties. When the script has been created, the SI should be enabled, so that the script does not fail in case of small changes. But the developer of the script should always check for the test results to verify if the SI feature was used to identify a object or not. Sometimes SI needs to be disabled for particular objects in the OR, this is advisable when you use SetTOProperty to change any of the TO properties of an object and especially ordinal identifiers like index, location and creationtime.
Descriptive Programming
Descriptive programming is nothing but a technique using which operations can be performed on the AUT object which are not present in the OR[Object Repository]
Recovery Scenarios
What is a Recovery Scenario?
Recovery scenario gives you an option to take some action for recovering from a fatal error in the test. The error could range in from occasional to typical errors. Occasional error would be like "Out of paper" popup error while printing something and typical errors would be like "object is disabled" or "object not found". A test case have more then one scenario associated with it and also have the priority or order in which it should be checked.
What does a Recovery Scenario consists of?
Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup window, any test error, particular state of an object or any application error.
Action: Action defines what needs to be done if scenario has been triggered. It can consist of a mouse/keyboard event, close application, call a recovery function defined in library file or restart windows. You can have a series of all the specified actions.
Post-recovery operation: Basically defined what need to be done after the recovery action has been taken. It could be to repeat the step, move to next step etc....
When to use a Recovery Scenario and when to us on error resume next?
Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won't occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper", as this error is caused by printer device driver. "On error resume next" should be used when you know if an error is expected and dont want to raise it, you may want to have different actions depending upon the error that occurred. Use err.number & err.description to get more details about the error.
Library files
Library Files or VBScript FilesHow do we associate a library file with a test ?
Library files are files containing normal VBScript code. The file can contain function, sub procedure, classes etc.... You can also use executefile function to include a file at run-time also. To associate a library file with your script go to Test->Settings... and add your library file to resources tab.
When to associate a library file with a test and when to use execute file?
When we associate a library file with the test, then all the functions within that library are available to all the actions present in the test. But when we use Executefile function to load a library file, then the function are available in the action that called executefile. By associated a library to a test we share variables across action (global variables basically), using association also makes it possible to execute code as soon as the script runs because while loading the script on startup QTP executes all the code on the global scope. We can use executefile in a library file associated with the test to load dynamic files and they will be available to all the actions in the test.
Add-ins
Test and Run-time ObjectWhat is the difference between Test Objects and Run Time Objects ?
Test objects are basic and generic objects that QTP recognize. Run time object means the actual object to which a test object maps.
Can i change properties of a test object
Yes. You can use SetTOProperty to change the test object properties. It is recommended that you switch off the Smart Identification for the object on which you use SetTOProperty function.
Can i change properties of a run time object?
No (but Yes also).
You can use GetROProperty("outerText") to get the outerText of a object but there is no function like SetROProperty to change this property. But you can use
WebElement().object.outerText="Something" to change the property.
Action & Functions
What is the difference between an Action and a function?
Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a object repository associated with it while a function can't. A function is just lines of code with some/none parameters and a single return value while an action can have more than one output parameters.
Where to use function or action?
Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action. Code specific to QTP can also be put into an function using DP. Decision of using function/action depends on what any one would be comfortable using in a given situation.
Checkpoint & Output value
What is checkpoint?
Checkpoint is basically a point in the test which validates for truthfulness of a specific things in the AUT. There are different types of checkpoints depending on the type of data that needs to be tested in the AUT. It can be text, image/bitmap, attributes, XML etc....
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.
Environment
How can i import environment from a file on disk
Environment.LoadFromFile "C:\Env.xml"
How can i check if a environment variable exist or not?
When we use Environment("Param1").value then QTP expects the environment variable to be already defined. But when we use Environment.value("Param1") then QTP will create a new internal environment variable if it does not exists already. So to be sure that variable exist in the environment try using Environment("Param1").value.
How to connect to a database?
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD="
objRecordset.CursorLocation = adUseClientobjRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source="select field1,field2 from testTable"
ObjRecordset.ActiveConnection=ObjConnection
ObjRecordset.Open 'This will execute your Query
If ObjRecordset.recordcount>0 then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End if
Read On 0 comments

Maximize a browser window from QTP

To maximizw a browser window that is controlled by a QTP script, use the code :

object.Fullscreen

eg : Browser("XYZ").fullscreen

Enjoy : post more and help others...

Read On 0 comments
 

About me | Author Contact | Powered By Blogspot | © Copyright  2008