Saturday, October 9, 2010

QTP FAQ

Which scripting language used by QTP?
Actually QTP is using only one language called VB script. But it also provide access to its functions and properties through its object(s). You can use any other scripting language to access the QTP, but you will not get the any benefit of its recording technique and other facilities provided by tool.

How many types of recording facility are available in QTP?
QTP provides three types of recording methods:
1. Context Recording (Normal) - It's an default option
2. Low Level Recording :
Suppose there is a application with Textbox or Editbox that requires some input. So if you are using normal recording it will only record only charcters.
3. Analog Recording
It will recorded some of non character keys too, like backspace Left Arrow, Right Arrow, etc. This is generally used when you are not able to record any of the object properly or when you want to record other events like mouse and keybord actions. This is much more sensitive then above two options. Suppose if you have a application like MS word and you want to record some drawing with mouse you will not be able to do this with the above two. You require this option to enable.

Drawback : Once recorded, you cannot edit it. Re-recording is the only solution.

What is Page checkpoint and How to add a page checkpoint to your test?
It checks the number of links and images on the page when you run your test is the same as when you recorded your test.
a. Locate the page where you want to add a page checkpoint.
b. 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.
c. Save the test.

What is the Diff between Image check-point and Bit map Check point?
Image Checkpoints checks the properties of the image and not the Actual image. So Through image check points you can verify it index, ALT Tag, URL of the image.
While the Bitmap check points actually checks the image Comparing bit by bit. Through this you can check the whole image or part of the image.

How to close all the Internet expolere windows and their dialog boxes
SystemUtil.CloseProcessByName("IEXPLORE.exe")

How to open the browser through script?
a) To open Firefox
SystemUtil.Run "firefox.exe", URL, , , SHOW_MAXIMIZED

b) To open Internet Explorer
SystemUtil.Run "iexplorer.exe", URL, , , SHOW_MAXIMIZED

How to retrive the whole text of the page ?
var = Browser("title:= title").page("title:=title").Object.documentElement.innertext

OR

var = Browser("title:= title").page("title:=title").WebElement("html tag:=BODY").getROProperty("innertext")

How to add array and retrieve the Dictionary Object ?
Function DicDemo
Dim a, d, i, s, arr(2) ' Create some variables.
Set d = CreateObject("Scripting.Dictionary")
arr(0)=0
arr(1)=1
arr(2)=2
d.Add "Arr", arr
a = d.Items ' Get the items.
newarr=a(0)
For i=0 to ubound(newarr)
msgbox newarr(i)
Next
End Function

Call DicDemo


How to retrieve the static text of the Dialog Box
Dialog("text:=MyWindow").Static(nativeclass:=Static").GetROProperty("text")

OR

Dialog("text:=MyWindow").Static(nativeclass:=Static","Index:=0").GetROProperty("text")

How to store the double quoted text in the variable ?
strname= """puneet"""
msgbox strname

strname= chr(34)&"puneet"&chr(34)
msgbox strname

How to close all the opened browsers ?
While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").Close
Wend

Creation time is a special property associated with the Browser Object. The value of this property show the order in which the browser has opened. The First Browser that opens receives the Value 0. And so when you close the first Browser the value of this property in all the browser decrease by 1.


What is the file extension of the code file & object repository file in QTP?
Ans) for object repositories file the extension is .tsr
for code file the extension is .vbs

Explain the concept of object repository & how QTP recognises objects?
Ans) 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 in QTP?
Ans) Title is the property we use.ex: Browser("Title:="xxx").page("Title:="xxxx").....
"Name" would be another property apart from "title" that we can use.

Ex: Browser ("name:="xxx"").page("name:="xxxx"").....

What are the different scripting languages you could use when working with QTP?
Ans) Visual Basic Script,XML,JavaScript,Java,HTML

Give me an example where you have used a COM interface in your QTP project?
[as per your project]

Explain the keyword createobject with an example.
Ans) Creates and returns a reference to an Automation object . 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.
Ans) Essentially all configuration and run functionality provided via the QuickTest interface is in some way represented in the QuickTest automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QuickTest 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 QuickTest automation object model, along with standard programming elements such as loops and conditional statements to design your program

What are the Features & Benefits of Quick Test Pro(QTP)..?
Ans) Operates stand-alone, or integrated into Mercury Business Process Testing and Mercury Quality Center.
Introduces next-generation “zero-configuration” Keyword Driven testing technology in QuickTest 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?
Ans) 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?
Ans) Output values enable to view the values that the application takes 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.

13) QTP pros and cons
Ans) Pros:
• Ease of use.
• Simple interface.
• Presents the test case as a business workflow to the tester (simpler to understand).
• Numerous features.
• Uses a real programming language (Microsoft’s VBScript) with numerous resources available.
• QuickTest Pro is significantly easier for a non-technical person to adapt to and create working test cases, compared to WinRunner.
• Data table integration better and easier to use than WinRunner.
• Test Run Iterations/Data driving a test is easier and better implement with QuickTest.
• Parameterization easier than WinRunner.
• Can enhance existing QuickTest scripts without the “Application Under Test” being available; by using the ActiveScreen.
• Can create and implement the Microsoft Object Model (Outlook objects, ADO objects, FileSystem objects, supports DOM, WSH, etc.).
• Better object identification mechanism.
• Numerous existing functions available for implementation – both from within QuickTest Pro and VBScript.
• QTP supports .NET development environment (currently WinRunner 7.5 does not).
• XML support (currently WinRunner 7.5 does not).
• The Test Report is more robust in QuickTest compared to WinRunner.
• Integrates with TestDirector and WinRunner (can kick off WinRunner scripts from QuickTest).
Cons:
• Currently there are fewer resources (consultants and expertise) available due to QTP being a newer product on the market and because there is a greater Demand than Supply, thus fewer employee/consulting resources.
• Must know VBScript in order to program at all.
• Must be able to program in VBScript in order to implement the real advance testing tasks and to handle very dynamic situations.
• Need training to implement properly.
• The Object Repository (OR) and “testing environment” (paths, folders, function libraries, OR) can be difficult to understand and implement initially.


Answer 1: How can we do the Analysis of Results in QTP?

The Test Results window contains a graphic and text summary of the results of a run as well as details of each step in the run.

To view the results of a run:

1. If the Test Results window is not already open, click the Results button or choose Automation (menu) > Results.

Tip: You can open the Test Results window as a standalone application from the Start menu. To open the Test Results window, choose Start > Programs > QTP Professional > Test Results Viewer.

1. If there are test results for the current test, they are displayed in the Test Results window.

2. If there are several test results for the current test, or if there are no test results for the current test, the Open Test Results dialog box opens. You can select the test results for any test, or you can search for the test results (results.xml) file anywhere in the file system. Click Open to display the selected results in the Test Results window.

Note: Results files for QTP Professional are saved with a .qtp file extension.

The following example shows the results of a test with three iterations:

(Click on the above image to see the large view)

2. You can view the results of an individual iteration, an action, or a step. When you select a step in the test results tree, the right side of the Test Results window contains the details of the selected step. Depending on your settings in the Run tab of the Options dialog box, the right side of the Test Results window may be split into two panes, with the bottom pane containing a still image (or in selected cases, other data) of the selected step. The right pane may also contain a movie of your application.

3. Viewing Results of Tests Run From Quality Center

When you run test sets containing QTP tests from Quality Center, the Quality Center server opens QTP on the host computer and runs the tests from that computer. All run results are then saved to the default location for those tests.

You can view the results of QTP tests run from Quality Center. If your results include a movie of your application, the movie can be viewed in Quality Center.


Answer 2: After creating the test, what is the purpose of running them?

The major Purpose of running the test scripts are Checking and testing the application. And confirm that there are no major bugs in the application and working fine as per the business rules.

Also we run the test scripts to update the test scripts by running the test in the update mode and debug the the script by running I debug mode.

See why QTP is majorly used?

HP QTP Professional software provides functional and regression test automation for major software applications and environments, including next-generation development technologies, such as Windows® Presentation Foundation, Web services, Macromedia Flex, Ajax, Delphi, PowerBuilder, .NET, J2EE and enterprise resource planning (ERP), and customer relationship management (CRM) applications.

HP QTP Professional offers a fresh approach to automated testing: It deploys the concept of keyworddriven testing to radically simplify test creation and maintenance. Using keyword capabilities, your testers can build test cases by capturing flows directly from the application screens and applying robust capturing technology (record/replay). In addition, your power users get full access to the underlying test and object properties through an integrated scripting and debugging environment that is synchronized with the Keyword View capability for your complete testing cycle.

With HP QTP Professional, your quality assurance (QA) organization can:

- Empower the entire team to create sophisticated test suites with less training.
- Establish correct functionality across all environments, data sets, and business processes.
- Fully document and replicate defects for developers, helping them fix defects faster and meet production deadlines.
- Easily regression test ever-changing applications and environments.
- Deliver quality products and services and improve revenues and profitability.
- Enable tester workgroups to share automated testing assets across teams.


Answer 3: I have a Microsoft Access database that contains data I would like to use in my test. How do I do this?

The Expert View enables you to access databases using ADO and ODBC. Below is a sample test that searches for books written by an author in the "Authors" table of the database.

Dim MyDB
Dim MyEng
Set MyEng = CreateObject("DAO.DBEngine.35")
Dim Td
Dim rs
' Specify the database to use.
Set MyDB = MyEng.OpenDatabase("BIBLIO.MDB")
' Read and use the name of the first 10 authors.
Set Td = MyDB.TableDefs("Authors")
Set rs = Td.OpenRecordset
rs.MoveFirst
For i = 1 To 10
Browser("Book Club").Page("Search Books").WebEdit("Author Name").Set rs("Author")
Browser("Book Club").Page("Search Books").WebButton("Search").Click
Next

Answer 4: Can we create many external variable files with same names & different values?

Of course YES. For localization testing we are using this and this is very efficient way for localization testing.

With the same variable name and different variable values, one can create many external variable files. And using the different file each time, we can run the test as many times we want.

Answer 5: Can we use Data Driver to parameterize the VBScript functions in QTP?

You cannot use the Data Driver to parameterize the values of arguments for user-defined methods or VBScript functions. []

Notes from From HP QTP User Guide:

Notes:

- When finding multiple occurrences of a selected value, QTP conducts a search that is case sensitive and searches only for exact matches. (It does not find values that include the selected value as part of a longer string.)

- You cannot use the Data Driver to parameterize the values of arguments for user-defined methods or VBScript functions.

Answer 6: How can we add the same comment to every action that we create?

If you want to add the same comment to every action that you create, you can add the comment to an action template

To create an action template:

1. Create a text file containing the comments, function calls, and other statements that you want to include in your action template. The text file must be in the structure and format used in the Expert View.

2. Save the text file as ActionTemplate.mst in your \dat folder. All new actions you create contain the script lines from the action template.

Note: Only the file name ActionTemplate.mst is recognized as an action template.

Answer 7: How can we check a current data value with a value stored in a database in QTP?

Date base Checkpoint in QTP: You create a database checkpoint based on the results of the query (result set) you defined on a database. You can create a check on a database to check the contents of the entire result set, or a part of it. QTP captures the current data from the database, saves this information as expected data, and inserts a database checkpoint into the test. This checkpoint is displayed in the Expert View as a DbTable.Check CheckPoint statement and as a step in the Keyword View, as follows:
(Click on the image to see clear view)


When you run the test, the database checkpoint compares the current data in the database to the expected data defined in the Database Checkpoint Properties dialog box. If the expected data and the current results do not match, the database checkpoint fails. You can view the results of the checkpoint in the Test Results window.

You can modify the expected data of a database checkpoint before you run your test. You can also make changes to the query in an existing database checkpoint. This can be useful if you move the database to a new location on the network.

Answer 8: How can we check if an environment variable exists or not?

(Source: QA Forums)

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.

If you need to test for the existence of an environment variable, you might consider using:

if not "%var%"=="" @echo var=%var%

While this works, a better method is:

if defined var @echo var=%var%

Try this little test:
@echo off
setlocal
if not "%var%"=="" @echo line 3 %var%
if defined var @echo line 4 %var%
set var=hello world
if not "%var%"=="" @echo line 6 %var%
if defined var @echo line 7 %var%
endlocal

Answer 9: Can I store functions and subroutines in a function library?

You can define functions within an individual test, or you can create one or more VBScript function libraries containing your functions, and then call them from any test or use them in any component.

You can also register your functions as methods for QTP test objects. Your registered methods can override the functionality of an existing test object method for the duration of a run session, or you can register a new method for a test object class.

Answer 10: How can we check the contents of tables in our application in QTP?

By adding table checkpoints to the test, we can check the content of tables displayed in the application. For example, we can check that a specified value is displayed in a certain cell. Certain environments also support checking the properties of the table object.

For example, a check that a table has the expected number of rows and columns. A table checkpoint can also be created by inserting a standard checkpoint on a table object.

Answer 11: How we check the databases accessed by our application in QTP?

The contents of a database accessed by your application can be checked by Database Checkpoint. Database checkpoints are supported for all add-in environments

Answer 12: How can we check the location of a cell to be checked in a Column of a table?

The settings in the Cell Identification tab determine how QTP locates the cells to be checked. The settings in this tab apply to all selected cells.

The Cell Identification tab includes the following options:

i. Identify columns : Specifies the location of the column (in your actual table) containing the cell(s) to which you want to compare the expected data.

• By position. (Default) Locates cells according to the column position. A shift in the position of the columns within the table results in a mismatch.

• By column name. Locates cells according to the column name. A shift in the position of the columns within the table does not result in a mismatch. (Enabled only when the table contains more than one column.)

ii. Identify rows : Specifies the location of the row (in your actual table) containing the cell(s) to which you want to compare the expected data.

• By row number. (Default) Locates cells according to the row position. A shift in the position of any of the rows within the table results in a mismatch.

• By selected key column(s). Locates the row(s) containing the cells to be checked by matching the value of the cell whose column was previously selected as a key column. A shift in the position of the row(s) does not result in a mismatch. If more than one row is identified, QTP checks the first matching row. You can use more than one key column to uniquely identify any row.

Note: A key symbol is displayed in the header of selected key columns.

iii. Use value match criteria to identify data in the key column: Instructs QTP to use the verification type settings from the Settings tab as the criteria for identifying data in the key column.

Enabled only when you select to identify rows By selected key column(s).

Answer 13: How do I make the QTP test prompt the user for input while it is running ?

The VBScript InputBox function enables you to display a dialog box that prompts the user for input and then continues running the test. You can use the value that was entered by the user later in the run session. For more information on the InputBox function, refer to the VBScript Reference.

The following example shows the InputBox function used to prompt the user for a password.

Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Set "administrator"
Passwd = InputBox ("Enter password", "User Input")
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("password").Set Passwd

Answer 14: How can we check the location of a cell to be checked in a Row of a table?

The settings in the Cell Identification tab determine how QTP locates the cells to be checked. The settings in this tab apply to all selected cells.

Identify rows : Specifies the location of the row (in your actual table) containing the cell(s) to which you want to compare the expected data.

• By row number. (Default) Locates cells according to the row position. A shift in the position of any of the rows within the table results in a mismatch.

• By selected key column(s). Locates the row(s) containing the cells to be checked by matching the value of the cell whose column was previously selected as a key column. A shift in the position of the row(s) does not result in a mismatch. If more than one row is identified, QTP checks the first matching row. You can use more than one key column to uniquely identify any row.

Answer 15: How can we check the object property values in our application?

You can check the object property values in your Web site or application using standard checkpoints. Standard checkpoints compare the expected values of object properties captured during recording to the object's current values during a run session.

You use standard checkpoints to perform checks on images, tables, Web page properties, and other objects within your application or Web site.

Note: You can create standard checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded).

Answer 16: How can we compare objects among two object repositories in QTP?

Using the Object Repository Comparison Tool, you can compare two object repositories according to predefined settings that define how differences between objects are identified.

To compare two object repositories:

1. In QTP Professional, choose Resources > Object Repository Manager.

2. In the Object Repository Manager, choose Tools > Object Repository Comparison Tool. The New Comparison dialog box opens on top of the Object Repository - Comparison Tool window.
(click on the below image to see clear view)

Answer 17: How can we compare the image files in the Image Checkpoint in QTP?

Image checkpoints enable you to check the properties of a Web image. In the Image Checkpoint Properties dialog box, you can specify which properties of the image to check and edit the values of those properties. This dialog box is similar to the standard Checkpoint Properties dialog box, except that it contains the Compare image content option. This option enables you to compare the expected image source file with the actual image source file.

Answer 18: How can we create a QTP Test in Quality Center?

To create a business process test, the Subject Matter Expert selects (drags and drops) the components that apply to the business process test and configures their run settings.

Note: When you run a business process test from Quality Center, the test run may also be influenced by settings in the QTP Remote Agent.

Each component can be used differently by different business process tests. For example, in each test the component can be configured to use different input parameter values or run a different number of iterations.

If, while creating a business process test, the Subject Matter Expert realizes that a component has not been defined for an element that is necessary for the business process test, the Subject Matter Expert can submit a component request from the Test Plan module.

Answer 19: How can I record and run tests on objects that change dynamically from viewing to viewing?

Sometimes the content of objects in a Web page or application changes due to dynamic content. You can create dynamic descriptions of these objects so that QTP will recognize them when it runs the test.

Answer 20: How can we debug a Function Library?

Before you can debug a function library, you must first associate it with a component (via its application area) and then insert a call to at least one of its functions. For example, you can use the Debug Viewer to view, set, or modify the current value of objects or variables in your function library. You can step into functions (including user-defined functions), set breakpoints, stop at breakpoints, view expressions, and so forth. You can begin debugging from a specific step, or you can instruct QTP to pause at a specific step.

Note: During a debug session, all documents are read-only and cannot be edited. To edit a document during a debug session, you must first stop the debug session.

After you create a component or function library (including registered user functions), you should check that they run smoothly, without errors in syntax or logic. To debug a function library, you must first associate it with a component via its application area and then debug it from that component.

To detect and isolate defects in a component or function library, you can control the run session using the Pause command as well as various step commands that enable you to step into, over, and out of a specific step.

You can use the Debug from Step command to begin your debug session at a specific point in your component. You can also use the Run to Step command to pause the run at a specific point in your component. You can set breakpoints, and then enable and disable them as you debug different parts of your component or function library.

When the component or function library run stops at a breakpoint, you can use the Debug Viewer to check and modify the values of VBScript objects and variables. Also, if QTP displays a run error message during a run session, you can click the Debug button on the error message to suspend the run and debug the component or function library.

You can also use the Run from Step command to run your component or function library from a selected step to the end. This enables you to check a specific section of your application or to confirm that a certain part of your component or function library runs smoothly.

Notes:

- While the component and function libraries are running in debug mode, they are read-only. You can modify the content after you stop the debug session (not when you pause it). If needed, you can enable the function library for editing (File > Enable Editing) after you stop the session.

After you implement your changes, you can continue debugging your component and function libraries.

- If you perform a file operation (for example, open a different component or create a new component), the debug session is stopped.

- In QTP, when you open a component, QTP creates a local copy of the external resources that are saved to your Quality Center project. Therefore, any changes you apply to any external resource that is saved in your Quality Center project, such as a function library, will not be implemented in the component until the component is closed and reopened. (An external resource is any resource that was not created using QTP, such as, a function library created in an external editor.)


How can we define a time interval for QTP to perform a checkpoint successfully?

You can specify the time interval during which QTP attempts to perform the checkpoint successfully by modifying the selections in the bottom part of the Text/Text Area Checkpoint Properties dialog box. You can also specify when to perform the checkpoint.
• Checkpoint timeout. Specifies the time interval (in seconds) during which QTP attempts to perform the checkpoint successfully. QTP continues to perform the checkpoint until it passes or until the timeout occurs. If the checkpoint does not pass before the timeout occurs, the checkpoint fails.
For example, suppose it takes some time for an object to achieve an expected state. Increasing the checkpoint timeout value in this case can help ensure that the object has sufficient time to achieve that state, enabling the checkpoint to pass (if the data matches) before the maximum timeout is reached.
If you specify a checkpoint timeout other than 0, and the checkpoint fails, the Test Results window displays information on the checkpoint timeout.
• Insert statement. Specifies when to perform the checkpoint. Choose Before current step if you want to check the value of the text before the highlighted step is performed. Choose After current step if you want to check the value of the text after the highlighted step is performed.
Note: The Insert statement option is not available when adding a new text checkpoint or a text area checkpoint during recording, or when modifying an existing checkpoint. It is available only when adding a new text checkpoint to an existing test while editing.

How can we Disable Smart Identification During the Run Session in QTP?

Selecting the Enable Smart Identification check box for a particular test object class instructs QTP to learn the property values of all properties specified as the object's base and/or optional filter properties in the Smart Identification Properties dialog box.

By default, some test objects already have Smart Identification configurations and others do not. Those with default configurations also have the Enable Smart Identification check box selected by default.

You should enable the Smart Identification mechanism only for test object classes that have defined Smart Identification configuration. However, even if you define a Smart Identification configuration for a test object class, you may not always want to learn the Smart Identification property values. If you do not want to learn the Smart Identification properties, (To Disable Smart Identification in QTP) clear the Enable Smart Identification check box.

Note: Even if you choose to learn Smart Identification properties for an object, you can disable use of the Smart Identification mechanism for a specific object in the Object Properties or Object Repository dialog box.
However, if you do not learn Smart Identification properties, you cannot enable the Smart Identification mechanism for an object later.

How can we do part running of the QTP Test script?
The Run from Step option in the Test menu is used to run the test from a selected step to the end of the current action, if running from the Expert View, or to the end of the test , if running from the Keyword View. Thus it enables us to check a specific part of the application or to confirm that a certain part of the test runs correctly.

How can I check by QTP that a child window exists (or does not exist)?
Sometimes a link in one window creates another window.
You can use the Exist property to check whether or not a window exists. For example:
Browser("Window_name").Exist
You can also use the ChildObjects method to retrieve all child objects (or the subset of child objects that match a certain description) on the Desktop or within any other parent object.

How can we do the nesting of If...Then...Else statement in QTP?
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements] . . .
[Else
[elsestatements]
End If

How can we ensure that a text string appears in a specified area in QTP?
In the Text/Text Area Checkpoint Properties dialog box, you can specify the text to be checked as well as which text is displayed before and after the checked text. These configuration options are particularly helpful when the text string you want to check appears several times or when it could change in a predictable way during run sessions.

For example, suppose you want to check the third occurrence of a particular text string in a page. To check for this string, you can specify which text precedes and/or follows it and to which occurrence of the specified text string you are referring.

7. How can we identify a checkpoint in QTP?
QTP enables you to add checks to your test. A checkpoint is a verification point that compares a current value for a specified property with the expected value for that property. This enables you to identify whether your Web site or application is functioning correctly.

When you add a checkpoint, QTP adds a checkpoint to the current row in the Keyword View and adds a Check CheckPoint statement in the Expert View. By default, the checkpoint name receives the name of the test object on which the checkpoint is being performed. You can choose to specify a different name for the checkpoint or accept the default name.

When you run the test, QTP compares the expected results of the checkpoint to the current results. If the results do not match, the checkpoint fails. You can view the results of the checkpoint in the Test Results window.

Tip: You can also use the CheckProperty method and the CheckItemProperty method to check specific property or item property values.

Note: If you want to retrieve the return value of a checkpoint (a boolean value that indicates whether the checkpoint passed or failed), you must add parentheses around the checkpoint argument in the statement in the Expert View. For example:

a = Browser("MyBrowser").Page("MyPage").Check (CheckPoint("MyProperty"))

How can we incorporate decision-making into the QTP tests?
Using conditional statements, you can incorporate decision making into your tests. Using loop statements, you can run a group of steps repeatedly, either while or until a condition is true. You can also use loop statements to repeat a group of steps a specific number of times.
After you insert a conditional or loop statement in the Keyword View, you can insert or record steps after the statement to include them in the conditional or loop block.

How can we increase the Readability of our QTP Tests scripts?
To increase readability, use With Statement.
You can instruct QTP to automatically generate With statements for the steps you record. When you select this option, statements are displayed in their normal format while recording. When you stop recording, the statements in all actions recorded during the current recording session are automatically converted to the With format.

To generate With statements automatically when you record:
1. Choose Tools > Options or click the Options toolbar button. The Options dialog box opens.
2. In the General tab, select Automatically generate "With" statements after recording.
3. Enter the minimum number of consecutive, identical objects for which you want to apply the With statement in the Generate "With" statements for __ or more objects box.
The default is 2.

Note: This setting is used when you use the Apply "With" to Script option as well as for the Automatically generate "With" statements after recording option.

For example, if you only want to generate a With statement when you have three or more consecutive statements based on the same object, enter 3.

4. Begin recording your test. While recording, statements are recorded normally. When you stop recording, the statements in all actions recorded during the current recording session are automatically converted to the With format.
The With statement has the following syntax.
With object
.....statement
.....statement
.....statement
End With

For example, you could replace this script:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "19097 LON "
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

with the following:

With Window("Flight Reservation")
.WinComboBox("Fly From:").Select "London"
.WinComboBox("Fly To:").Select "Los Angeles"
.WinButton("FLIGHT").Click
With .Dialog("Flights Table")
.WinList("From").Select "19097 LON "
.WinButton("OK").Click
End With 'Dialog("Flights Table")
End With 'Window("Flight Reservation")

Note: Using With statements in your test has no effect on the run session itself, only on the way your test appears in the Expert View. Generating With statements for your test does not affect the Keyword View in any way.

How does QTP record on dynamically generated URLs and Web pages?
QTP actually clicks links as they are displayed on the page. Therefore, QTP records how to find a particular object, such as a link on the page, rather than the object itself. For example, if the link to a dynamically generated URL is an image, then QTP records the "IMG" HTML tag, and the name of the image. This enables QTP to find this image in the future and click on it.


How can we insert a checkpoint or output value statement in Expert View of QTP Manually?
We cannot insert standard checkpoints and other predefined checkpoints or output value statement in Expert View of QTP Manually.
But we can insert descriptive checkpoints (Like If… Else) in the expert view of QTP while editing/updating the test scripts.

How can we Insert statement option when adding a checkpoint during the recording?

How can we Integrate QTP with Quality Center?
At its most basic level, integrating QTP with Quality Center enables you to store and access QTP tests and function libraries in a Quality Center project, when QTP is connected to Quality Center.

In addition, your tests and function libraries can use the QCUtil object to access and use the full functionality of the Quality Center OTA (Open Test Architecture)—formerly known as TestDirector OTA or TDOTA. This enables you to automate integration operations during a run session, such as reporting a defect directly to a Quality Center database.
You can also use the TDOTA object in your QTP automation scripts to access the Quality Center OTA.

How can we locate Test Objects in an Object Repository in QTP?
You can select an object in the application or Web site you are testing and highlight the test object in the object repository.

For example, to locate a Find a Flight image in a Web page, you can select it in your Web page using the pointing hand mechanism. After you select the Find a Flight image object from the selection dialog box and click OK, the parent hierarchy in the object repository tree expands and the Find a Flight image test object is highlighted.

To locate an object in the object repository:
1. Make sure your application or Web site is open to the correct window or page.
2. Click the Locate in Repository button or choose View > Locate in Repository. QTP is hidden, and the pointer changes into a pointing hand.
3. Use the pointing hand to click on the required object in your application or Web site.

Tip: You can hold the left CTRL key to change the window focus or perform operations such as right-clicking or moving the pointer over an object to display a context menu. If the window containing the object you want to click is partially hidden by another window, you can also hold the pointing hand over the partially hidden window for a few seconds until the window comes into the foreground and you can point and click on the object you want. Additionally, if the window containing the object you want to select is minimized, you can display it by holding the left CTRL key, right-clicking the application in the Windows task bar, and choosing Restore from the context menu.
If the location you clicked is associated with more than one object, the Select an Object dialog box opens.
4. Select the object you want to locate in the object repository and click OK. The selected object is highlighted in the object repository.
5.
Tip: If the relevant object repository is not open or the object cannot be found, the object is not highlighted. In the Object Repository Manager, if more than one shared object repository is open, and QTP cannot locate the selected object in the active object repository, you can choose whether to look for the object in all of the currently open object repositories.

How does QTP handle cookies?
Server side connections, such as CGI scripts, can use cookies both to store and retrieve information on the client side of the connection.
QTP stores cookies in the memory for each user, and the browser handles them as it normally would.

How can we parameterize a step in QTP?
Parameterize the method argument of the fromPort step:

In the Keyword View, click in the Value cell of the step and then click the parameterization icon. In the Value Configuration Options dialog box, select the Parameter radio button. In the Name box, rename p_item to Location.

Click OK. The Location column is added to the Data Table.

How can we perform Import & Export Operations among various Object Repositories in QTP?
You can export all of the objects contained in an action's local object repository to a new shared object repository in the file system or to a Quality Center project (if QTP is connected to Quality Center). This enables you to make the local objects accessible to other actions. You export local objects to a new shared object repository using the Object Repository window.

To export local objects to a new shared object repository:
1. Open the test that has the local objects you want to export.
2. Make sure that the Object Repository window is open.
3. In the Object Repository window, in the Action box, choose the action whose local objects you want to export.
4. Choose File > Export Local Objects. The Export Object Repository dialog box opens.

Note: If you are connected to Quality Center, the dialog box that opens is different from the standard file system dialog box. You can switch between the two dialog box versions by clicking the File System and Quality Center buttons in the Export Object Repository dialog box.
5. Select the location in which to save the file, specify the file or attachment name, and click Save or OK (depending on whether you are saving it to the file system or a Quality Center project).
The object repository is exported to the specified shared object repository (a file with a .tsr extension). You can now use the new shared object repository like any other shared object repository.

Tip: After you export the local objects, you can use the Object Repository Merge Tool to merge the shared object repository containing the exported objects with another shared object repository.

How can we perform Merge Operations among various Object Repositories in QTP?
QTP Professional provides the ability to merge existing assets from two object repositories into a single shared object repository using the Object Repository Merge Tool. This tool enables you to merge two shared object repositories (called the primary object repository and the secondary object repository), into a new third object repository, called the target object repository. Objects in the primary and secondary object repositories are automatically compared and then added to the target object repository according to preconfigurable rules that define how conflicts between objects are resolved.

After the merge process, the Object Repository Merge Tool provides a graphic presentation of the original objects in the primary and secondary object repositories, which remain unchanged, as well as the objects in the merged target object repository. Objects that had conflicts are highlighted. The conflict of each object that you select in the target object repository is described in detail. The Object Repository Merge Tool provides specific options that enable you to keep the suggested resolution for each conflict, or modify each conflict resolution individually, according to your requirements.

The Object Repository Merge Tool also enables you to merge objects from the local object repository of one or more actions into a shared object repository. For example, if QTP learned objects locally in a specific action in your test, you may want to add the objects to the shared object repository, so that they are available to all actions in different tests that use that object repository.
You open the Object Repository Merge Tool by choosing Tools > Object Repository Merge Tool in the Object Repository Manager.

How can we retrieve all objects located inside a Parent Object with QTP?
You can use the ChildObjects method to retrieve all objects located inside a specified parent object, or only those child objects that fit a certain programmatic description. To retrieve this subset of child objects, you first create a description object and add the set of properties and values that you want your child object collection to match using the Description object.
Note: You must use the Description object to create the programmatic description for the ChildObjects description argument. You cannot enter the programmatic description directly into the argument using the property:=value syntax.

Once you have "built" a description in your description object, use the following syntax to retrieve child objects that match the description:

Set MySubSet=TestObject.ChildObjects(MyDescription)
For example, the statements below instruct QTP to select all of the check boxes on the Itinerary Web page:
Set MyDescription = Description.Create()
MyDescription("html tag").Value = "INPUT"
MyDescription("type").Value = "checkbox"
Set Checkboxes = Browser("Itinerary").Page("Itinerary").ChildObjects(MyDescription)
NoOfChildObjs = Checkboxes.Count
For Counter=0 to NoOfChildObjs-1
Checkboxes(Counter).Set "ON"
Next

In the Test Results, square brackets around a test object name indicate that the test object was created dynamically during the run session using the ChildObjects method or a programmatic description.

Where can I find a Web page's cookie with QTP?
The cookie used by the browser can be accessed through the browser's Document Object Model (DOM). In the following example the cookie collection is returned the from the browser.
Browser("Flight reservations").Page("Flight reservations").Object.Cookie
SPONSORED LINKS


41. How can we run standard DOS commands in QTP tests?

You can run standard DOS commands in your QTP test or function using the VBScript Windows Scripting Host Shell object (WSCript.shell).

For example, you can open a DOS command window, change the path to C:\, and run the DIR command using the following statements:

Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C:\ & Dir"
Set oShell = Nothing

For more information, refer to the Microsoft VBScript Language Reference (choose Help > QTP Professional Help > VBScript Reference > VBScript).

42. How can we switch to Low Level Recording mode while editing a test script in QTP?

You can switch to Low Level Recording mode only while recording a test. The option is not available while editing a test. [source: HP QTP User Guide]

43. How can we verify the data content of XML files in QTP?

By adding XML checkpoints to your tests, you can verify that the data and structure in your XML documents or files has not changed unexpectedly. When you run your test, QTP compares the expected results of the checkpoint to the actual results of the run session. If the results do not match, the checkpoint fails.

You can verify the data content of XML files with XML checkpoints. A few common uses of XML checkpoints are described below:

An XML file can be a static data file that is accessed to retrieve commonly used data for which a quick response time is needed—for example, country names, zip codes, or area codes. Although this data can change over time, it is normally quite static. You can use an XML file checkpoint to validate that the data has not changed from one application release to another.

An XML file can consist of elements with attributes and values (character data). There is a parent and child relationship between the elements, and elements can have attributes associated with them. If any part of this hierarchy (including data) changes, your application's ability to process the XML file may be affected. Using an XML checkpoint, you can check the content of an element to make sure that its tags, attributes, and values have not changed.

Web service operations often return XML values. If the Web Service Add-in is installed on your computer, you can send a Web service operation command to the service and use an XML checkpoint to verify that the service returns the XML in the expected structure and with the expected values.

XML files are often an intermediary that retrieves dynamically changing data from one system. The data is then accessed by another system using Document Type Definitions (DTD), enabling the accessing system to read and display the information in the file. You can use an XML checkpoint and parameterize the captured data values if you want to check an XML document or file whose data changes in a predictable way.
XML documents and files often need a well-defined structure to be portable across platforms and development systems. One way to accomplish this is by developing an XML schema, which describes the structure of the XML elements and data types. You can use schema validation to check that each item of content in an XML file adheres to the schema description of the element in which the content is to be placed.

44. How do we analyze our application to determine our testing needs using QTP?

1) Determine the development environments that QTP needs to support: Our application comprises of windows containing a hierarchy of objects that were created in one or more development environments. QTP provides support for these environments using add-ins. We load QTP add-ins when QTP opens by using the Add-in Manager dialog box. We can check which add-ins are loaded by choosing Help > About QTP.

45. How do we compare actual cell values with the expected cell values in Tables in QTP?.

The Settings tab includes options that determine how the actual cell values are compared with the expected cell values. For example, you can instruct QTP to treat the value as a number so that 45 or 45.00 are treated as the same value, or you can instruct QTP to ignore spaces when comparing the values. The settings in this tab apply to all selected cells.


(click on he above image to see the clear view)
The default setting is to treat cell values as strings and to check for the exact text, while ignoring spaces.

The Settings tab includes the following options:

Verification type
Exact match
Ignore space
Match case
Min / Max

46. How does QTP handle session IDs?

The server, not the browser, handles session IDs, usually by a cookie or by embedding the session ID in all links. This does not affect QTP.

47. How do we store output values in Environment Variable?

When you define an output value, you can specify where and how each value is stored during the run session.

You can output a value to:
- a test or action parameter
- the run-time Data Table
- an environment variable

When you output a value to an internal user-defined environment variable, you can use the environment variable input parameter at a later stage in the run session.

Note: You can output values only to internal user-defined environment variables and not to external or built-in environment variables, which are read-only.

For example, suppose you are testing an application that prompts the user to input an account number on a Welcome page and then displays the user's name. You can use a text output value to capture the value of the displayed name and store it in an environment variable.

You can then retrieve the value in the environment variable to enter the user's name in other places in the application. For example, in an Order Checkbook Web page, which for security reasons requires users to enter the name to appear on the checks, you could use the value to insert the user's name into the Name edit box.

48. How do we store output values in Run-time Data Table?

The option to output a value to the run-time Data Table is especially useful with a data-driven test (or action) that runs several times. In each repetition, or iteration, QTP retrieves the current value and stores it in the appropriate row in the run-time Data Table.

For example, suppose you are testing a flight reservation application and you design a test to create a new reservation and then view the reservation details. Every time you run the test, the application generates a unique order number for the new reservation. To view the reservation, the application requires the user to input the same order number. You do not know the order number before you run the test.

To solve this problem, you output a value to the Data Table for the unique order number generated when creating a new reservation. Then, in the View Reservation screen, you use the column containing the stored value to insert the output value into the order number input field.

When you run the test, QTP retrieves the unique order number generated by the site for the new reservation and enters this output value in the run-time Data Table. When the test reaches the order number input field required to view the reservation, QTP inserts the unique order number stored in the run-time Data Table into the order number field.

49. How do we store output values in Test and Action Parameters?

You can output a value to an action parameter, so that values from one part of a run session can be used later in the run session, or be passed back to the application that ran (called) the test.

For example, suppose you are testing a shopping application that calculates your purchases and automatically debits your account with the amount that you purchased. You want to test that the application correctly debits the purchase amount from the account each time that the action is run with a different list of items to purchase. You could output the total amount spent to an action parameter value, and then use that value later in your run session in the action that debits the account.

50. How do we use Random Number Parameters for Non-Numeric Values?

- Random number parameters are not appropriate for non-numeric values, such as text or hypertext links.

- If you select an existing parameter, then changing the settings in the dialog box affects all instances of that parameter in the test.

- You can also define random number variables using parameterization objects and methods in the Expert View.

51. How do we use Regular Expressions in Checkpoints?

When creating a standard checkpoint to verify the property values of an object, you can set the expected value of an object's property as a regular expression so that an object with a varying value can be verified.

For example, suppose you want to check that every window and dialog box in your application contains the name of your application followed by a hyphen (-) and a descriptive title. You can add a checkpoint to each dialog box object in your test to check that the first part of the title contains the name of your application followed by a hyphen.

When creating a text checkpoint to check that a varying text string is displayed on your Web site or application, you can define the text string as a regular expression.

For example, when booking a flight in the Mercury Tours sample Web site, the total cost charged to a credit card number should not be less than $300. You define the amount as a regular expression, so that QTP will ignore variations in the text string as long as the value is not less than $300.

You can apply the same principles to any checkpoint type whose dialog box contains a Configure Value area.

For example, for table checkpoints you can set cell values as regular expressions, and for XML checkpoints you can set attribute or element values as regular expressions. For more information on specific checkpoint types, see the relevant section for the checkpoint type.

52. How does QTP handle server redirections?

When the server redirects the client, the client generally does not notice the redirection, and misdirections generally do not occur. In most cases, the client is redirected to another script on the server. This additional script produces the HTML code for the subsequent page to be viewed. This has no effect on QTP or the browser.

53. How do we use User-Defined External Environment Variables in QTP?

You can create a list of variable-value pairs in an external file in .xml format. You can then select the file as the active external environment variable file for a test and use the variables from the file as parameters.

You can set up your environment variable files manually, or you can define the variables in the Environment tab of the Test Settings dialog box and use the Export button to create the file with the correct structure.

Notes:

- You can also store environment variable files in Quality Center.

- You can create several external variable files with the same variable names and different values and then run the test several times, using a different file each time. This is especially useful for localization testing.

If you create your files manually, you must use the correct format, as defined below. You can use the QTP environment variable file schema in:
\help\QTEnvironment.xsd

54. How many types of Actions are there in QTP?

When you create a test, it includes one action. All the steps you record and all the modifications you make while editing your test are part of a single action.

You can divide your test into multiple actions by creating new actions and inserting calls to them, or by inserting calls to existing actions.

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.

55. How many types of Checkpoints are available in QTP?

You can insert the following checkpoint types to check various objects in a Web site or application.

Standard Checkpoint checks the property value of an object in your application or Web page. The standard checkpoint checks a variety of objects such as buttons, radio buttons, combo boxes, lists, and so forth. For example, you can check that a radio button is activated after it is selected or you can check the value of an edit box.
Standard checkpoints are supported for all add-in environments (see Supported Checkpoints).

Image Checkpoint checks the value of an image in your application or Web page. For example, you can check that a selected image's source file is correct.
Note: You create an image checkpoint by inserting a standard checkpoint on an image object.

Image checkpoints are supported for the Web add-in environment (see Supported Checkpoints).

Bitmap Checkpoint checks an area of your Web page or application as a bitmap. 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.
Bitmap checkpoints are supported for all add-in

Table Checkpoint checks information within a table. For example, suppose your application or Web site contains a table listing all available flights from New York to San Francisco. You can add a table checkpoint to check that the time of the first flight in the table is correct.

Note: You create a table checkpoint by inserting a standard checkpoint on a table object.

Text Checkpoint checks that a text string is displayed in the appropriate place on a Web page or application. For example, suppose a Web page displays the sentence Flight departing from New York to San Francisco. You can create a text checkpoint that checks that the words "New York" are displayed between "Flight departing from" and "to San Francisco".
Text checkpoints are supported for most add-in

Text Area Checkpoint checks that a text string is displayed within a defined area in a Windows application, according to specified criteria. For example, suppose your Visual Basic application has a button that says View Doc , where is replaced by the four digit code entered in a form elsewhere in the application. You can create a text area checkpoint to confirm that the number displayed on the button is the same as the number entered in the form.
Text area checkpoints are supported for Standard Windows, Visual Basic, and ActiveX add-in environments.

Text area checkpoints are also supported for some external add-in environments, such as Java.

Accessibility Checkpoint identifies areas of your Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines. For example, guideline 1.1 of the W3C Web Content Accessibility Guidelines requires you to provide a text equivalent for every non-text element. You can add an Alt property check to check whether objects that require the Alt property under this guideline, do in fact have this tag.
Accessibility checkpoints are supported for the Web add-in.

Page Checkpoint checks the characteristics of a Web page. For example, you can check how long a Web page takes to load or whether a Web page contains broken links.
Note: You create a page checkpoint by inserting a standard checkpoint on a page object.

Page checkpoints are supported for the Web add-in environment.

Database Checkpoint checks the contents of a database accessed by your application. For example, you can use a database checkpoint to check the contents of a database containing flight information for your Web site.
Database checkpoints are supported for all add-in environments.

XML Checkpoint checks the data content of XML documents in XML files or XML documents in Web pages and frames.
The XML Checkpoint (Web Page/Frame) option is supported for the Web add-in environment. The XML Checkpoint option is supported for all add-in environments

56. How many types of element checks are available in XML Checkpoints in QTP?

The following element checks are available:
Check number of attributes: Checks the number of attributes that are attached to the element.

Check number of child element occurrences in block: Displays the number of child elements associated with the selected parent element. If you select this option, QTP verifies that the number of child elements in your XML tree (with the specified name, if applicable) corresponds to the number that appears in the Check number of child element occurrences in block field.

You can specify the child element name for the Number of child element occurrences check. If you select a child element name, QTP verifies that the number of child elements with that name corresponds to the number that you specify in the Number of child element occurrences in block field.

Select Any Child (default) to check the total number of child elements associated with the selected parent element.

57. How many types of main views of a script are available in QTP?

Two views of Scripts are available in QTP:



Keyword View in QTP
The Keyword View enables you to create and view the steps of your test in a keyword-driven, modular, table format. The Keyword View is comprised of a table-like view, in which each step is a separate row in the table, and each column represents different parts of the steps. You can modify the columns displayed to suit your requirements.

You create and modify tests by selecting items and operations in the Keyword View and entering information as required. Each step is automatically documented as you complete it, enabling you to view a description of your test steps in understandable English.

Each operation performed on your application or Web site during a recording session is recorded as a row in the Keyword View.

For each row in the Keyword View, QTP displays a corresponding line of script in the Expert View. If you focus on a specific step in the Keyword View and switch to the Expert View, the cursor is located in that corresponding line of the test.

Note: The Keyword View replaces the Tree View found in earlier versions of QTP. Many of the operations you could perform from the Tree View can be performed in a similar manner from the Keyword View. For example, right-click on a step to access context-sensitive options for that step, such as checkpoint, output value and action-related operations.

Expert View in QTP
In the Expert View, QTP displays each operation performed on your application in the form of a script, comprised of VBScript statements. The Expert View is a script editor with many script editing capabilities. For each object and method in an Expert View statement, a corresponding row exists in the Keyword View. For more information on using the Expert View

58. How does QTP handle meta tags?

Meta tags do not affect how the page is displayed. Generally, they contain information only about who created the page, how often it is updated, what the page is about, and which keywords represent the page's content. Therefore, QTP has no problem handling meta tags.

59. How many types of Parameters are there in QTP?

There are four types of parameters in QTP:

Test/action parameters. Test parameters enable you to use values passed from your test. Action parameters enable you to pass values from other actions in your test.
To use a value within a specific action, you must pass the value down through the action hierarchy of your test to the required action. You can then use that parameter value to parameterize a step in your test. For example, suppose that you want to parameterize a step in Action3 using a value that is passed into your test from the external application that runs (calls) your test. You can pass the value from the test level to Action1 (a top-level action) to Action3 (a nested action of Action1), and then parameterize the required step using this action input parameter value (that was passed through from the external application).

Alternatively, you can pass an output action parameter value from an action step to a later sibling action at the same hierarchical level. For example, suppose that Action2, Action3, and Action4 are sibling actions at the same hierarchical level, and that these are all nested actions of Action1. You can parameterize a call to Action4 based on an output value retrieved from Action2 or Action3. You can then use these parameters in your action step.

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, QTP uses a different value from the Data Table.
For example, suppose your application or Web site includes a feature that enables users to search for contact information from a membership database. When the user enters a member's name, the member's contact information is displayed, together with a button labelled View 's Picture, where is the name of the member. You can parameterize the name property of the button using a list of values so that during each iteration of the run session, QTP can identify the different picture buttons.

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 QTP generates for you based on conditions and options you choose.
For example, you can have QTP read all the values for filling in a Web form from an external file, or you can use one of QTP's built-in environment variables to insert current information about the computer running the test.

Random number parameters. Enable you to insert random numbers as values in your test. For example, to check how your application handles small and large ticket orders, you can have QTP generate a random number and insert it in a number of tickets edit box.

60. How QTP identifies various Objects?

QTP recognizes all objects in the Application under test using the set of mandatory properties that it stores for all Test Objects while recording. If QTP is not able to recognize the objects using the set of mandatory properties it uses another set of properties called the assistive properties. In case the assistive properties are also not enough to uniquely identify an object QTP resorts to using the ordinal identifiers for the object that are properties like the index, location and time of creation of the object. If all this fails QTP resorts to the smart identification mechanism.

Understanding How QTP Identifies Objects During the Run Session
QTP also uses a very human-like technique for identifying objects during the run session.

Suppose as a continuation to the experiment, Alex is now asked to identify the same "item" he initially identified but in a new, yet similar environment.

The first photograph he is shown is the original photograph. He searches for the same Caucasian girl, about eight years old, with long, brown hair that he was asked to remember and immediately picks her out. In the second photograph, the children are playing on the playground equipment, but Alex is still able to easily identify the girl using the same criteria.

Similarly, during a run session, QTP searches for a run-time object that exactly matches the description of the test object it learned while recording. It expects to find a perfect match for both the mandatory and any assistive properties it used to create a unique description while recording. As long as the object in the application does not change significantly, the description learned during recording is almost always sufficient for QTP to uniquely identify the object. This is true for most objects, but your application could include objects that are more difficult to identify during subsequent run sessions.


61. How QTP recognizes objects in Object Repositories?

In QTP, the Object Repository window displays a tree of all objects in the current component or in the selected action (including all local objects and all objects in any shared object repositories associated with the selected action or component).

we can view or modify the test object description of any test object in the repository or to add new objects to the repository.
QTP 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.


62. Does QTP work with .asp?

Dynamically created Web pages utilizing Active Server Page technology have an .asp extension. This technology is completely server-side and has no bearing on QTP.


63. How QTP retrieves Text while checking the text during the test?

You can check that a specified text string is displayed by adding one of the following checkpoints to your test.

* Standard Checkpoint. Enables you to check the text property of an object. You can use standard checkpoints to check text in Windows-based and other types of applications (including Web-based applications).
* Text Area Checkpoint. Enables you to check that a text string appears within a defined area in a Windows application, according to specified criteria. It is supported for Standard Windows, Visual Basic, and ActiveX environments. Text area checkpoints are also supported for various external QTP Professional add-ins. Refer to your add-in documentation for details.
* Text Checkpoint. Enables you to check that the text is displayed in a screen, window, or Web page, according to specified criteria. Text checkpoints are supported for many add-in environments (as listed in Supported Checkpoints). Text checkpoints are also supported for various external QTP Professional add-ins. Refer to your add-in documentation for details.

When checking text, QTP tries to retrieve the text directly from the test object. If QTP cannot retrieve the text (for example, because the text is part of a picture), it tries to retrieve the text using an OCR (optical character recognition) mechanism.

64. How results are generated in QTP?

When a run session ends, you can view the run session results in the Test Results window. By default, the Test Results window opens automatically at the end of a run. If you want to change this behavior, clear the View results when run session ends check box in the Run tab of the Options dialog box.

The Test Results window contains a description of the steps performed during the run session. For a test that does not contain Data Table parameters, the Test Results window shows a single test iteration.

If the test contains Data Table parameters, and the test settings are configured to run multiple iterations, the Test Results window displays details for each iteration of the test run. The results are grouped by the actions in the test.

Note: You set the test to run for one or all iterations in the Run tab of the Test Settings dialog box.

After you run a test, the Test Results window displays all aspects of the run session, including:

* a high-level results overview report (pass/fail status)
* the data used in all runs
* an expandable tree of the steps, specifying exactly where application failures occurred
* the exact locations in the test where failures occurred
* a still image of the state of your application at a particular step
* a movie clip of the state of your application at a particular step or of the entire test
* detailed explanations of each step and checkpoint pass or failure, at each stage of the test

Note: The Test Results window can show results with up to 300 levels in the tree hierarchy. If you have results with more than 300 nested levels, you can view the entire report by manually opening the results.xml file.


65. How the output values are stored during the run sessions in QTP?

When you define an output value, you can specify where and how each value is stored during the run session.

You can output a value to:

* a test or action parameter
* the run-time Data Table
* an environment variable

Note: Output values are stored only for the duration of the test, and are not saved with the test. If you select to output a value to an existing parameter, Data Table column, or environment variable, the existing value is overwritten when the output value step runs. When the run session ends, the original value is restored.

66. How to use Environment Variable Files with Quality Center?

67. When working with Quality Center and environment variable files, you must save the environment variable file as an attachment in your Quality Center project before you specify the file in the Environment tab of the Test Settings dialog box.

You can add a new or an existing environment variable file to your Quality Center project. Note that adding an existing file from the file system to a Quality Center project creates a copy of the file in Quality Center. Thus, once you save the file to the project, changes made to the Quality Center environment variable file will not affect the file system file and vice versa.

To use an environment variable file with Quality Center:

1. To add a new environment variable file, create a new .xml file in your file system.
2. In Quality Center, add the file to the project as an attachment. For more information, refer to your Quality Center documentation.
3. In QTP, connect to the Quality Center project.
4. In the Test Settings dialog box, click the Environment tab.
5. Select User-defined from the Variables type list.
6. Select Load variables and values from external file (reload each run session).
7. In the File box, click the browse button to find the user-defined variable file in the Quality Center project.
8. Save your test. QTP saves the file to the Quality Center project.


68. Does QTP work with COM?

QTP complies with the COM standard.

QTP supports COM objects embedded in Web pages (which are currently accessible only using Microsoft Internet Explorer) and you can drive COM objects in VBScript.


69. In what situations recording mechanism shall be useful in creating tests in QTP?

Click on the below link to read answer:

http://www.onestopsoftwaretesting.com/2008/11/in-what-situations-recording-mechanism.html


70. In what situations we output a value for a step in a test action?


71. Is there any built-in function for Scripting in QTP?

QTP uses an in-built functionality called "Step Generator" to create scripts while appropriate steps are entered into it.

The Step Generator enables you to add steps by selecting from a range of context-sensitive options and entering the required values. In the Step Generator dialog box you can define steps that use:

* test object methods and properties (tests only)
* Utility object methods and properties
* calls to library functions (tests only), VBScript functions, and internal script functions

For example, you can add a step that checks that an object exists, or that stores the returned value of a method as an output value or as part of a conditional statement. You can parameterize any of the values in your step.

Note: You can use the Step Generator to insert steps in tests and function libraries. However, in function libraries, you cannot use the Step Generator to access test object names or collections, or to access the list of library functions.

Before you open the Step Generator to define a new step, you first select where in your test the new step should be inserted.

After you open the Step Generator, you first select the category for the step operation (test object, Utility object or function) and the required object or the function library source (for example, built-in or local script functions). You can then select the appropriate method or function and define the arguments and return values, parameterizing them if required.

The Step Generator then inserts a step with the correct syntax into your test. You can continue to add further steps at the same location without closing the Step Generator.

You can open the Step Generator from the Keyword View or Expert View while recording or editing your test. You can also open the Step Generator from the Active Screen while editing.


72. Please explain some real world scenario explaining Object Learning process of QTP?

QTP learns objects just as you would. For example, suppose as part of an experiment, Alex is told that he will be shown a photograph of a picnic scene for a few seconds during which someone will point out one item in the picture. Alex is told that he will be expected to identify that item again in identical or similar pictures one week from today.

Before he is shown the photograph, Alex begins preparing himself for the test by thinking about which characteristics he wants to learn about the item that the tester indicates. Obviously, he will automatically note whether it is a person, inanimate object, animal, or plant. Then, if it is a person, he will try to commit to memory the gender, skin color, and age. If it is an animal, he will try to remember the type of animal, its color, and so forth.

The tester shows the scene to Alex and points out one of three children sitting on a picnic blanket. Alex notes that it is a Caucasian girl about 8 years old. In looking at the rest of the picture, however, he realizes that one of the other children in the picture could also fit that description. In addition to learning his planned list of characteristics, he also notes that the girl he is supposed to identify has long, brown hair.

Now that only one person in the picture fits the characteristics he learned, he is fairly sure that he will be able to identify the girl again, even if the scene the tester shows him next week is slightly different.

Since he still has a few moments left to look at the picture, he attempts to notice other, more subtle differences between the child he is supposed to remember and the others in the picture—just in case.

If the two similar children in the picture appeared to be identical twins, Alex might also take note of some less permanent feature of the child, such as the child's position on the picnic blanket. That would enable him to identify the child if he were shown another picture in which the children were sitting on the blanket in the same order.

QTP uses a very similar method when it learns objects during the recording process.

First, it "looks" at the object on which you are recording and stores it as a test object, determining in which test object class it fits. Just as Alex immediately checked whether the item was a person, animal, plant, or thing. QTP might classify the test object as a standard Windows dialog box (Dialog), a Web button (WebButton), or a Visual Basic scroll bar object (VbScrollBar), for example.

Then, for each test object class, QTP has a list of mandatory properties that it always learns; similar to the list of characteristics that Alex planned to learn before seeing the picture. When you record on an object, QTP always learns these default property values, and then "looks" at the rest of the objects on the page, dialog box, or other parent object to check whether this description is enough to uniquely identify the object. If it is not, QTP adds assistive properties, one by one, to the description, until it has compiled a unique description; like when Alex added the hair length and color characteristics to his list. If no assistive properties are available, or if those available are not sufficient to create a unique description, QTP adds a special ordinal identifier, such as the object's location on the page or in the source code, to create a unique description, just as Alex would have remembered the child's position on the picnic blanket if two of the children in the picture had been identical twins.

73. Splitting Actions option is not available under what circumstances in QTP?

You can split an action that is stored with your test into two sibling actions or into parent-child nested actions. When you split an action, the second action starts with the step that is selected when you perform the split action operation.

You cannot split an action and the option is disabled when:

* an external action is selected
* the first step of an action is selected
* recording a test
* running a test
* you are working with a read-only test

74. What are Absolute and Relative Paths in QTP?

absolute path: It means Direct path,
relative Path: It means indirect path

You can save QTP resources, such as shared object repositories, function libraries, recovery scenarios or environments, using absolute or relative paths.

1) An absolute path: Describes the full path to a specific file starting from a fixed location such as the root directory, or the drive on which the file is located, and contains all the other sub-directories in the path. An absolute path always points to the specified file, regardless of the current directory.

2) A relative path: Describes the path to a specific file starting from a given directory, and is generally only a portion of the absolute path. A relative path therefore specifies the location of the file relative to the given location in the file system.

Using relative paths means that the paths remain valid when files or folders containing files are moved or copied to other locations or computers, provided that they are moved within the same folder structure. For this reason, we recommend that we use relative paths when saving resources in QTP.

so u can do it in two ways :
1.absolute path : C:\more\mna\users\bsp\hello.txt
so absolute path means full path of file or directory starting with "/" root of directory structure

2.relative path : users\bsp\hello.txt

75. Does QTP work with XML?

XML is eXtensible Markup Language, a pared-down version of SGML for Web documents, that enables Web designers to create their own customized tags. QTP supports XML and recognizes XML tags as objects. QTP also supports XML output and schema validation.

By adding XML checkpoints in QTP to your test scripts, you can check the contents of individual XML data files or documents that are part of your Web application.


76. What are Conditional and Loop Statements used in the Keyword View in QTP?

Using conditional statements, you can incorporate decision making into your tests. Using loop statements, you can run a group of steps repeatedly, either while or until a condition is true. You can also use loop statements to repeat a group of steps a specific number of times. Each statement type is indicated by one of the following icons in the Keyword View:

After you insert a conditional or loop statement in the Keyword View, you can insert or record steps after the statement to include them in the conditional or loop block.


77. What are Data Tables in QTP?

The data your test uses is stored in the design-time Data Table, which is displayed in the Data Table pane at the bottom of the screen while you insert and edit steps.

The Data Table has the characteristics of a Microsoft Excel spreadsheet, meaning that you can store and use data in its cells and you can also perform mathematical formulas within the cells. You can use the DataTable, DTSheet and DTParameter utility objects to manipulate the data in any cell in the Data Table.

Note: The use of complex and/or nested formulas in the Data Table is not supported.

You can insert Data Table parameters and output values into your test. Using Data Table parameters and/or output values in a test enables you to create a data-driven test or action that runs several times using the data you supply. In each repetition, or iteration, QTP uses a different value from the Data Table.

During the run session, QTP creates a run-time Data Table—a live version of the Data Table associated with your test. During the run session, QTP displays the run-time data in the Data Table pane so that you can see any changes to the Data Table as they occur.

When the run session ends, the run-time Data Table closes, and the Data Table pane again displays the stored design-time Data Table. Data entered in the run-time Data Table during the run session is not saved with the test. The final data from the run-time Data Table is displayed in the Run-Time Data Table in the Test Results window.

Tip: If it is important for you to save the resulting data from the run-time Data Table, you can insert a DataTable.Export statement to the end of your test to export the run-time Data Table to a file. You can then import the data to the design-time Data Table using the Data Table File > Import From File menu. Alternatively you can add a DataTable.Import statement to the beginning of your test to import the run-time Data Table that was exported at the end of the previous run session.

78. What are Nesting Actions in QTP & what is the use of them?

Sometimes you may want to call an action from within an action. This is called nesting. By nesting actions, you can:

* Maintain the modularity of your test.
* Run one or more actions based on the results of a conditional statement.

For example, suppose you have parameterized a step where a user selects one of three membership types as part of a registration process. When the user selects a membership type, the page that opens depends on the membership type selected in the previous page. You can create one action for each type of membership. Then you can use If statements to determine which membership type was selected in a particular iteration of the test and run the appropriate action for that selection.


79. What are Object Repositories in QTP?

When QTP runs a test, it simulates a human user by moving the pointer over the application, clicking objects, and entering keyboard input. Like a human user, QTP must learn the interface of an application to be able to work with it. QTP does this by learning the application's objects and their corresponding property values and storing these object descriptions in an object repository.

As QTP learns the test objects, it stores them in the action's local object repository. You can choose to keep the stored objects in the local object repository, or you can choose to store the objects in a shared object repository. Storing the objects in the local object repository makes them available only to the specific action, but not to other actions. Storing the objects in one or more shared object repositories enables multiple tests to use them. You can also work with a combination of local and shared object repositories, as needed. For more information on local and shared object repositories


80. What are Optional Steps in QTP?

An optional step is a step that is not necessarily required to successfully complete a run session. For example, suppose that when recording a test, the application you are testing prompts you to enter a user name and password in a login window. When you run the test, however, the application does not prompt you to enter your user name and password because it retained the information that was previously entered. In this case, the steps that were recorded for entering the login information are not required and should, therefore, be marked optional.

During a run session, if the object of an optional step does not exist, QTP bypasses this step and continues to run the test. When the run session ends, a message is displayed for the step indicating that the step was not performed, but the step does not cause the run to fail.

However, if, during a run session, QTP cannot find the object from the optional step in the object repository (for example, if the object name was modified in the test but not in the object repository, or if the object was removed from the object repository), an error message is displayed listing the required object, and the run fails.

During a recording, QTP automatically marks steps that open certain dialog boxes as optional. You can also manually designate steps as optional.


81. How can I access HTML tags directly in QTP?

QuickTest provides direct access to the browser's Document Object Model (DOM) through which you can access the HTML tags directly. Access to the DOM is performed using the .Object notation.

The test below demonstrates how to iterate over all the tags in a page. The test then outputs the inner-text of the tags (the text contained between the tags) to the Test Results using the Reporter object.

' Use the on error because not all the elements have inner-text.

On Error Resume Next

Set Doc = Browser("CNN Interactive").Page("CNN Interactive").Object

' Loop through all the objects in the page.

For Each Element In Doc.all

TagName = Element.TagName ' Get the tag name.

InnerText = Element.innerText ' Get the inner text.

' Write the information to the test results.

Reporter.ReportEvent 0, TagName, InnerText

Next


82. What are Permissions Required to Run QTP?

You must make sure the following access permissions are set in order to run QuickTest Professional.
Permissions Required to Run QuickTest Professional

You must have the following file system permissions:

* Full read and write permissions for all the files and folders under the folder in which QuickTest is installed
* Full read and write permissions to the Temp folder
* Read permissions to the Windows folder and to the System folder

You must have the following registry key permissions:

* Full read and write permissions to all the keys under HKEY_CURRENT_USER\Software\Mercury Interactive
* Read and Query Value permissions to all the HKEY_LOCAL_MACHINE and HKEY_CLASSES_ROOT keys

Permissions Required When Working with Quality Center

You must have the following permissions to use QuickTest with Quality Center:

* Full read and write permissions to the Quality Center cache folder
* Full read and write permissions to the QuickTest Add-in for Quality Center installation folder


83. What are the advantages of Keyword Driven testing in QTP?

Keyword-driven testing is a technique that separates much of the programming work from the actual test steps so that the test steps can be developed earlier and can often be maintained with only minor updates, even when the application or testing needs change significantly.

Advantages:

1. Although this methodology requires more planning and a longer initial time-investment than going directly to the test creation stage and recording your steps, this methodology makes the test creation and test maintenance stages more efficient and keeps the structure of individual tests more readable and easier to modify.
2. By creating your tests with a keyword-driven methodology in mind, your tests become more modular, focusing on the operations to test using both QuickTest built-in keywords and your own user-defined keywords.
3. It is possible to add objects to the object repository before they exist in an application; it is possible to begin preparing your automated keyword-driven tests even before a build containing the new objects is available.
4. By encapsulating much of the complex programming into function libraries, and by making these functions flexible enough to use in many testing scenarios (through the use of function parameters that control the way the functions behave), one or a few automation experts can prepare the keywords that many application testers who are less technical can include in multiple tests. This also makes it possible to update testing functionality without having to update all the tests that use the keywords.
5. Developing and documenting business-level keywords in function libraries. Creating function libraries involves developing customized functions for the application you want to test. You may want to develop functions to test special application functionality that is not already supplied by the methods in the QuickTest object model. It is also useful to wrap existing methods and functions together with additional programming to create application-specific functions for testing operations or sequences that are commonly performed in your application. The functions you create will be available either as extra keywords or as replacements for built-in QuickTest keywords during the test creation stage.


84. What are the contents of the Programming Statements used in QTP tests?

The easiest way to create a test is to begin by recording typical business processes that you perform on your application or Web site. Then, to increase the power and flexibility of your test, you can add steps that contain programming logic to the recorded framework. Programming statements can contain:

* recordable test object methods. These are operations that a user can perform on an application or Web site.
* non-recordable test object methods. These are operations that users cannot perform on an application or Web site. You use these methods to retrieve or set information, or to perform operations triggered by an event.
* run-time methods of the object being tested.
* various VBScript programming commands that affect the way the test runs, such as conditions and loops. These are often used to control the logical flow of a test.
* supplemental statements, such as comments, to make your test easier to read, and messages that appear in the test results, to alert you to a specified condition.


85. What are the Differences between Business Components and Tests in QTP?

In Business process testing the combination of components will become a test (business process test) Components are easily-maintained, reusable units that perform a specific task. They are the building blocks of business process tests. Each component is comprised of several application steps that are logically performed together in a specific order. For example, in a Web application, a login component might be comprised of four steps. Its first step could be to open the application. Its second step could be to enter a user name. Its third step could be to enter a password, and its last step could be to click the Submit button on the Web page. By creating and calling functions stored in
function libraries, you can enhance the component with additional logic to
test important details of the login task. By design, each component tests a specific part of an application. When combined, components are incorporated into a business process test in a serial flow representing the main tasks performed within a particular business process. The task of creating and running components and business process tests is generally performed by Subject Matter Experts working in Quality Center.

If you are already familiar with using QuickTest to create action-based tests, you will find that the procedures for creating and editing components are quite similar. However, due to the design and purpose of the component model, there are certain differences in the way you create, edit, and run components. The guidelines below provide an overview of these differences.

* A component is a single entity. It cannot contain multiple actions or have calls to other actions or to other components.
* When working with components, all external files are stored in the Quality Center project to which you are currently connected.
* The name of the component node in the Keyword View is the same as the saved component. You cannot rename the node.
* Business components are created in the Keyword View, not the Expert View.
* You add resources via the component's application area, and not directly to the component.
* Components use custom keywords created in function libraries to perform operations, such as verifying property values and opening the application you are testing.

86. What are the Elements of Recovery Scenario in QTP?

The Recovery Scenario Wizard leads you, step-by-step, through the process of creating a recovery scenario. The Recovery Scenario Wizard contains the following main steps Elements of Recovery Scenario in QTP:

* Defining the trigger event that interrupts the run session - Trigger Event: Is an unexpected event like appearance of a Pop-up window, object state, test run error causing application crash or interruption in our running session.

* Specifying the recovery operations required to continue - Recovery Steps: Constitutes a series of steps required to be performed to enable QTP to proceed further with the process of test after some trigger event has interrupted the run session. Examples of a recovery operation can be 1) A keyboard or mouse Operation like a Click over the “OK” button in the Pop-up window 2) Close Application Process 3) Function Call 4) Restarting the OS etc.

* Choosing a post-recovery test run operation - Post-Recovery Test Run: Are a set of instructions designed to be provided to QTP on proceeding further with the test after some recovery operation has been carried out. Examples of Post Recovery actions can be repeating the complete test from the beginning or some steps may be skipped altogether & continuing with the remaining steps in the test.
* specifying a name and description for the recovery scenario
* (for tests) specifying whether to associate the recovery scenario to the current test and/or to all new tests


87. What are the Environment Variables in QTP?

1) User-Defined Internal Variables: These are the variables that we define within the test. These variables are saved with the test and are accessible only within the test in which they were defined.

2) User-Defined External Variables: These are the variables that we predefine in the active external environment variables file. We can create as many files as we want and select an appropriate file for each test, or change files for each test run.

3) Built-in Variables: These are the variables that represent information about the test and the computer on which the test is run, such as Test path and Operating system. These variables are accessible from all tests, and are designated as read-only.


88. Where can I find information on the IE Document Object Model (NOT FOR INTERVIEW – IT IS FOR INFORMATION PURPOSE ONLY)?

For information on the IE DOM, browse to the following Web sites:

Document object: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp

Other DHTML objects: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects.asp

General DHTML reference: http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp


89. What are the key features of QTP at a glance?

Read -> http://www.onestopsoftwaretesting.com/2008/11/what-are-key-features-of-qtp-at-glance.html


90. What are the main stages of Testing with QTP?

Testing with QuickTest involves the following main stages:

1) Planning
2) Creating Tests
3) Running Tests
4) Analysing Results


91. What are the methods to populate the XML Tree in QTP?

When you create an XML checkpoint for a test object operation (for a WebService test object), the expected operation return value data cannot be generated. Therefore, only a generic XML tree is created. To check the operation return values, you must first populate the XML tree with the actual elements, attributes, and values that the operation is expected to return.

You can use one of the three methods below to populate the XML tree:

* Updating the XML Tree Manually
* Importing an XML Tree from a File
* Updating the XML Tree Using Update Run Mode


92. What are the modes available to open a function library in QTP?

You can open function libraries from the file system and function libraries that are part of a Quality Center project. You can open as many function libraries as you want. The QuickTest Script Editor works with .qfl, .vbs, and .txt function library files.

After you open a function library, it is displayed in a function library window in the display area, and the function library and its functions are displayed in the Opened Function Libraries folder at the top of the tree in the Resources pane. If the function library is associated with an open test, it is also displayed under the test as a function library link in the Associated Function Libraries folder in the tree in the Resources pane.

Tip: You can open an existing function library by dragging it from the file system (Windows Explorer) to the Script Editor window. You can open a recently used function library by selecting it from the Recent Files list in the File menu.

To open a function library:

1. Click the Quality Center Connection button and connect to Quality Center, if required. For more information on connecting to Quality Center, refer to the QuickTest Professional documentation.
2. Open the function library in one of the following ways:
* In the Resources pane, double-click the function library to open, or right-click the function library, and choose Show.
* Click the Open Function Library toolbar button, choose File > Open > Function Library, or press Ctrl+Shift+O. The Open Function Library dialog box opens. Select a function library, and click Open.

Note: The Open button toggles between Open Test and Open Function Library, according to the active window in the display area. To change the Open Test button to Open Function Library, click the arrow next to the button and then select Function Library, or click a function library window in the display area.

The window opens, and the function library is displayed in the Opened Function Libraries folder at the top of the tree in the Resources pane.

If you open a function library from the file system that is opened by another user, you are notified if changes are made by the other user, and given the option to accept or reject the changes made.

If you open a function library saved in Quality Center that is opened by another Quality Center user, you will be notified that the function library has been locked, and by whom, and that the function library will be opened in read-only mode. In addition, if you open a function library saved in Quality Center, it will be locked and no other user can modify it until you close it.


93. What are the options available for configuring Data Table Parameters in QTP?
Defining the Settings for a Data Table Parameter

The following options are available for configuring Data Table parameters:

Name. Specifies the name of the parameter in the Data Table. You can create a new parameter by using the default parameter name or entering a new, descriptive name. Alternatively, you can select an existing Data Table parameter from the list.

Note: The parameter name must be unique in the sheet. It can contain letters, numbers, periods, and underscores. The first character of the parameter name must be a letter or an underscore. If you specify an invalid name, QuickTest displays a warning message when you click OK. You can choose to edit the name manually or to instruct QuickTest to fix the name automatically (by adding an underscore at the beginning of the name).

Location in Data Table. Specifies whether to store the parameter in the global or current action sheet in the Data Table.


94. How can I send keyboard key commands (such as shortcut commands) to Web objects in QTP ?

For Web objects (or other objects that do not support the Type method), use the Windows Scripting SendKeys method.


95. What are the options available for configuring Environment Variable Parameters in QTP?

The following options are available for configuring environment variable parameters:

* Name. Specifies the name of the parameter. For an internal user-defined environment variable parameter, you can create a new parameter by using the default parameter name or entering a new, descriptive name. Alternatively, you can select an existing internal user-defined environment variable parameter from the list.

Notes:

If you edit the name displayed in the Name box for an existing parameter, you create a new internal user-defined environment variable parameter. The original environment variable parameter is not modified.

If you are parameterizing an argument that receives a predefined constant or number, only the environment variable parameters whose value is of type integer are shown in the Name list.

* Value. Specifies the value of the parameter. You can enter the value for a new user-defined internal parameter, or modify the value for an existing user-defined internal parameter. External and built-in environment variable parameter values cannot be modified in this dialog box.

If the entire value of a selected environment variable parameter cannot be displayed in the Value box, it is shown as [complex value]. For example, the value of a list's all items property is a multi-line value, where each line contains the value of an item in the list.

You can view or edit a complex value by clicking the View/Edit Complex Value button.

• Type. Specifies the type of environment variable parameter (read-only):

o internal user-defined
o external user-defined
o built-in

Tip: The value of an environment variable remains the same throughout the test run, regardless of the number of iterations, unless you change the value of the variable programmatically in your script.

* Regular expression. Sets the value of the parameter as a regular expression. This option is available only when parameterizing a checkpoint or object property text string value, and the selected environment variable parameter type is internal user-defined.


96. What are the options available when outputting a value to the Data Table in QTP?

Name. Specifies the name of the parameter in the Data Table. You can create a new parameter by using the default parameter name or entering a new, descriptive name. Alternatively, you can select an existing Data Table parameter from the list.

Note: The parameter name must be unique in the sheet. It can contain letters, numbers, periods, and underscores. The first character of the parameter name must be a letter or an underscore. If you specify an invalid name, QuickTest displays a warning message when you click OK. You can choose to edit the name manually or to instruct QuickTest to fix the name automatically (by adding an underscore at the beginning of the name).

Location in Data Table. Specifies whether to store the parameter in the global or current action sheet in the Data Table.

Advanced configuration (if applicable):

* Regular expression. Sets the value of the parameter as a regular expression. Note that this option is available only when parameterizing checkpoint and object property values.
* Use Data Table formula. (If applicable.) Inserts two columns in the Data Table. The first column contains a formula that checks the validity of output in the second column. QuickTest uses the data in the output column to compute the formula, and inserts a value of TRUE or FALSE in the table cell of the formula column. Note that this option is available only for checkpoints. For more information on using Data Table formulas,


97. What are the possibilities of Exporting the data among various Object Repositories in QTP?
Exporting Local Objects to an Object Repository in QTP

You can export all of the objects contained in an action's local object repository to a new shared object repository in the file system or to a Quality Center project (if QuickTest is connected to Quality Center). This enables you to make the local objects accessible to other actions. You export local objects to a new shared object repository using the Object Repository window.

When you export local objects to a shared object repository, the parameters of any parameterized objects are converted to repository parameters using the same name as the source parameter. The default (mapped) value of each repository parameter is the corresponding source parameter. You can modify the mapping used within your action using the Map Repository Parameters dialog box.

Tip: After you export the local objects, you can use the Object Repository Merge Tool to merge the shared object repository containing the exported objects with another shared object repository.

To export local objects to a new shared object repository:

1. Open the test that has the local objects you want to export.
2. Make sure that the Object Repository window is open.
3. In the Object Repository window, in the Action box, choose the action whose local objects you want to export.
4. Choose File > Export Local Objects. The Export Object Repository dialog box opens.

Note: If you are connected to Quality Center, the dialog box that opens is different from the standard file system dialog box. You can switch between the two dialog box versions by clicking the File System and Quality Center buttons in the Export Object Repository dialog box.

5. Select the location in which to save the file, specify the file or attachment name, and click Save or OK (depending on whether you are saving it to the file system or a Quality Center project).

The object repository is exported to the specified shared object repository (a file with a .tsr extension). You can now use the new shared object repository like any other shared object repository.


98. What are the Properties used by Smart Identification Feature of QTP?

The Smart Identification mechanism uses two types of properties:

Base Filter Properties. The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value, you could no longer call it the same object.
Optional Filter Properties. Other properties that can help identify objects of a particular class. These properties are unlikely to change on a regular basis, but can be ignored if they are no longer applicable.

Read More: http://www.onestopsoftwaretesting.com/2008/12/understanding-and-configuring-smart.html


99. What are the situations best suited for using an existing Checkpoint in QTP?

If the application contains multiple edit boxes, we can reuse a checkpoint to confirm the enabled status of these edit boxes throughout our test.

If the each webpage contains same logo and same text, then we can use existing Checkpoint.


100. How can I record on nonstandard menus in QTP?

You can modify how QuickTest behaves when it records menus. The options that control this behavior are located in the Advanced Windows Applications Options dialog box. (Tools > Options > Windows Applications > Advanced).


101. What are the situations best suited to Keyword-driven methodology in QTP?

You can create the steps in your tests using the keyword-driven methodology, recording, or a combination of both.

Recording can be useful in the following situations:

• Recording is useful for novice QTP users. It helps you to learn how QTP interprets the operations you perform on your application and how it converts them to QTP objects and built-in operations.

• For the same reasons as described above, recording is also useful for more advanced QTP users when working with a new application or major new features of an existing application. It is also helpful while developing functions that incorporate built-in QTP keywords.

• Recording can be useful when you need to quickly create a test that tests the basic functionality of an application or feature and does not require long-term maintenance.

Keyword-driven testing advantages include the following:

• Keyword-driven testing enables you to design your tests at a business level rather than at the object level. For example, QTP may recognize a single option selection in your application as several steps: a click on a button object, a mouse operation on a list object, and then a keyboard operation on a list sub-item. You can create an appropriately-named function to represent all of these lower-level operations in a single, business-level keyword.

• Similarly, by incorporating technical operations, such as a synchronization statement that waits for client-server communications to finish, into higher level keywords, tests are easier to read and easier for less technical application testers to maintain when the application changes.

• Keyword-driven testing naturally leads to a more efficient separation between resource maintenance and test maintenance. This enables the automation experts to focus on maintaining objects and functions while application testers focus on maintaining the test structure and design.

• When you record tests, you may not notice that new objects are being added to the local object repository. This may result in many testers maintaining local object repositories with copies of the same objects. When using a keyword-driven methodology, you select the objects for your steps from the existing object repository. When you need a new object, you can add it to your local object repository temporarily, but you are also aware that you need to add it to the shared object repository for future use.

• When you record a test, QTP enters the correct objects, methods, and argument values for you. Therefore, it is possible to create a test with little preparation or planning. Although this makes it easier to create tests quickly, such tests are harder to maintain when the application changes and often require re-recording large parts of the test.

When you use a keyword-driven methodology, you select from existing objects and operation keywords. Therefore, you must be familiar with both the object repositories and the function libraries that are available. You must also have a good idea of what you want your test to look like before you begin inserting steps. This usually results in well-planned and better-structured tests, which also results in easier long-term maintenance.

• Automation experts can add objects and functions based on detailed product specifications even before a feature has been added to a product. Using keyword-driven testing, you can begin to develop tests for a new product or feature earlier in the development cycle.


102. What are the situations best suited to Recording in QTP?

[Same as Above]


103. What are the special guidelines for Schema Validation?

Following are specific guidelines to consider when specifying a schema file to validate your XML.

• If you are validating an XML file using a schema defined in the XML file, the schema can be defined with an absolute or relative path. When you specify a relative path, QTP searches for the schema in the folders listed in the Folders tab of the Options dialog box.

• If you are validating an XML document located on the Web with a schema file located on your file system, you cannot use UNC format (for example, \\ComputerName\Path\To\Schema) to specify the schema file location. Instead, map the schema file location to a network drive.

• If there is a schema with a namespace defined in your XML document, the namespace of the external schema must be identical to the one defined in your document. Using an external XML schema file to validate an XML document may cause an unexpected result if the XML document has an XML schema declaration, and the namespace in the external schema file and the schema defined in the document are not identical.

• When you perform a schema validation, QTP validates all of the elements in the XML document, even if certain XML elements are not associated with a schema file. Any XML elements that are not associated with a schema file will cause the schema validation to fail.


104. What are the steps for implementing tests with Keyword Driven Methodology?

[See Answer: http://www.onestopsoftwaretesting.com/2008/11/what-are-steps-for-implementing-tests.html ]


105. What are the Test Object Properties in QTP?

For each object class, QTP learns a set of properties when it records and it uses this description to identify the object when it runs the test.

For example, by default, QTP learns the image type (such as plain image or image button), the html tag, and the Alt text of each Web image on which you record an operation.

(Click on the image to see large view)

If these three mandatory property values are not sufficient to uniquely identify the object within its parent object, QTP adds some assistive properties and/or an ordinal identifier to create a unique description.

When the test runs, QTP searches for the object that matches the description it learned. If it cannot find any object that matches the description, or if it finds more than one object that matches, QTP may use the Smart Identification mechanism to identify the object.

You can configure the mandatory, assistive, and ordinal identifier properties that QTP uses to record descriptions of the objects in your application, and you can enable and configure the Smart Identification mechanism.


106. How can I terminate an application in QTP that is not responding?

You can terminate any standard application while running a test in QTP by adding one of the following steps to the test:

o SystemUtil.CloseProcessByName "app.exe"

o SystemUtil.CloseProcessByWndTitle "Some Title"


107. What are the types of Environment Variables in QTP?

The Environment tab includes the following options for the Variable type:

• Built-in. Displays the built-in environment variables defined by QTP Professional and their current values.

• User-defined. Displays both internal and external user-defined environment variables and their current values.


108. What are the types of Ordinal Identifiers used by QTP to identify an object?

QTP can use the following types of ordinal identifiers to identify an object:

• Index. Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description. For more information, see Identifying an Object Using the Index Property.

• Location. Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description. For more information, see Identifying an Object Using the Location Property.

• CreationTime. (Browser object only.) Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. For more information, see Identifying an Object Using the CreationTime Property.

By default, an ordinal identifier type exists for each test object class. To modify the default ordinal identifier, you can select the desired type from the Ordinal identifier box.

Tip: While recording, if QTP successfully creates a unique test object description using the mandatory and assistive properties, it does not learn an ordinal identifier value. You can add an ordinal identifier to an object's test object properties at a later time using the Add/Remove option from the Object Properties or Object Repository dialog box.


109. What are the types of Programmatic Descriptions?

There are two types of programmatic descriptions:

• Static. You list the set of properties and values that describe the object directly in a VBScript statement.

• Dynamic. You add a collection of properties and values to a Description object, and then enter the Description object name in the statement.

Using the Static type to enter programmatic descriptions directly into your statements may be easier for basic object description needs. However, in most cases, using the Dynamic type provides more power, efficiency, and flexibility.


110. What are the values for which we can define the regular expression?

You can define a regular expression for a constant value, a Data Table parameter value, an Environment parameter value, or a property value in a programmatic description.


111. What are the various categories of output values in QTP?

1) Standard output values
2) Text and text area output values
3) Table output values
4) Database output values
5) XML output values


112. Can I copy and paste to and from the Clipboard during a run session?

You can use the Clipboard object to copy, cut, and paste text during a QTP run session.

The Clipboard object has the same methods as the Clipboard object available in Visual Basic:

o Clear

o GetData

o GetFormat

o GetText

o SetData

o SetText

Below is an example of Clipboard object usage:

Set MyClipboard = CreateObject("Mercury.Clipboard")

MyClipboard.Clear

MyClipboard.SetText "TEST"

MsgBox MyClipboard.GetText


113. What are the various events available in the Recovery Scenario Manager?

* Pop-up window. QTP detects a pop-up window and identifies it according to the window title and textual content. For example, a message box may open during a run session, indicating that the printer is out of paper. QTP can detect this window and activate a defined recovery scenario to continue the run session.

Select this option and click Next to continue to the Specify Pop-up Window Conditions Screen.

* Object state. QTP detects a specific test object state and identifies it according to its property values and the property values of all its ancestors. Note that an object is identified only by its property values, and not by its class.

For example, a specific button in a dialog box may be disabled when a specific process is open. QTP can detect the object property state of the button that occurs when this problematic process is open and activate a defined recovery scenario to close the process and continue the run session.

Select this option and click Next to continue to the Select Object Screen.

* Test run error. QTP detects a run error and identifies it by a failed return value from a method. For example, QTP may not be able to identify a menu item specified in the method argument, due to the fact that the menu item is not available at a specific point during the run session. QTP can detect this run error and activate a defined recovery scenario to continue the run session.

Select this option and click Next to continue to the Select Test Run Error Screen.

* Application crash. QTP detects an application crash and identifies it according to a predefined list of applications. For example, a secondary application may crash when a certain step is performed in the run session. You want to be sure that the run session does not fail because of this crash, which may indicate a different problem with your application. QTP can detect this application crash and activate a defined recovery scenario to continue the run session.

Select this option and click Next to continue to the Recovery Operations Screen.

Notes: The set of recovery operations is performed for each occurrence of the trigger event criteria. For example, suppose you define a specific object state, and two objects match this state, the set of recovery operations is performed two times, once for each object that matches the specified state.

The recovery mechanism does not handle triggers that occur in the last step of a test or component. If you need to recover from an unexpected event or error that may occur in the last step of a test or component, you can do this by adding an extra step to the end of your test or component.

114. What are the various Object Properties in QTP?

[See Answer 105]


115. What are the various options for configuring Random Number Parameters?
Defining Settings for a Random Number Parameter

The following options are available for configuring random number parameters:

* Numeric range. Specifies the range from which the random number is generated. By default, the random number range is between 0 and 100. You can modify the range by entering different values in the From and To boxes. The range must be between 0 and 2147483647 (inclusive).
* Name. Assigns a name to your parameter. Assigning a name to a random parameter enables you to use the same parameter several times in your test. You can select an existing named parameter or create a new named parameter by entering a new, descriptive name.
* Generate new random number. Defines the generation timing for a named random parameter. This box is enabled when you select the Name check box.
You can select one of the following options:
o For each action iteration. Generates a new number at the end of each action iteration.
o For each test iteration. Generates a new number at the end of each global iteration.
o Once per entire test run. Generates a new number the first time the parameter is used. The same number is used for the parameter throughout the test run.

Notes:

+ Random number parameters are not appropriate for non-numeric values, such as text or hypertext links.
+ If you select an existing parameter, then changing the settings in the dialog box affects all instances of that parameter in the test.
+ You can also define random number variables using parameterization objects and methods in the Expert View.


116. What are the various Recording Modes in QTP?

1. Normal mode

2. Analog mode

3. Low level recording


117. What are the various types of Exit Action Statements in QTP?

There are four types of exit action statements you can use:

* ExitAction. Exits the current action, regardless of its iteration attributes.
* ExitActionIteration. Exits the current iteration of the action.
* ExitRun. Exits the test, regardless of its iteration attributes.
* ExitGlobalIteration. Exits the current global iteration.


118. How do I maintain my test when my application changes?

The way to maintain a test when your application changes depends on how much your application changes. This is one of the main reasons you should create a small group of tests rather than one large test for your entire application. When your application changes, you can re-record part of a test. If the change is not significant, you can manually edit a test to update it.

You can also use QTP actions to design more modular and efficient tests. While recording, you divide your test into several actions, based on functionality. When your application changes, you can rerecord a specific action, without changing the rest of the test. Whenever possible, insert calls to reusable actions rather than creating identical pieces of script in several tests. This way, changes to your original reusable action are automatically applied to all tests calling that action.

If you have many tests and actions that contain the same test objects, it is recommended to work with shared object repositories so that you can update object information in a centralized location.

To update the information in your checkpoints, the Active Screen, or about your test object properties when object properties change, or to add new objects or steps on an Active Screen image without rerecording steps, use the Update Run Mode option.


119. What are the various types of objects identified by the comparison tool in QTP?

The Comparison Tool automatically identifies objects during the comparison process by classifying them into one of the following types:

* Identical. Objects that appear in both object repository files. There is no difference in their name or in their properties.
* Matching description, different name. Objects that appear in both object repository files that have different names, but the same description properties and values.
* Similar description. Objects that appear in both object repository files that have similar, but not identical, description properties and values. One of the objects always has a subset of the properties set of the other object. This implies that it is likely to be a less detailed description of the same object. For example, an object named Button_1 in the second object repository has the same description properties and values as an object named Button_1 in the first object repository, but also has additional properties and values.

Objects that do not have a description, such as Page or Browser objects, are compared by name only. If the same object is contained in both the object repositories but with different names, they will be shown in the object repositories as two separate objects.

Note: The Object Repository Comparison Tool gives precedence to matching object descriptions over the matching of object names. For this reason, certain object nodes may be linked during the comparison process and not others.

No comments:

Post a Comment

 

©2010 Software Testing powered by Free Blogger Templates | Author : Anand Satish