Interview

15 QTP Interview Questions and Answers

Prepare for your next interview with our comprehensive guide on QTP, featuring common and advanced questions to enhance your automated testing skills.

QuickTest Professional (QTP), now known as Micro Focus UFT (Unified Functional Testing), is a widely-used tool for automated functional and regression testing. It supports keyword and scripting interfaces and features a robust set of functionalities for testing web, desktop, and mobile applications. QTP’s integration with various test management tools and its ability to support multiple environments make it a valuable skill for software testers.

This article provides a curated selection of interview questions designed to help you demonstrate your proficiency with QTP. By reviewing these questions and their detailed answers, you can better prepare for technical interviews and showcase your expertise in automated testing.

QTP Interview Questions and Answers

1. What is QTP and its primary use?

QTP, now known as Micro Focus UFT (Unified Functional Testing), is an automated testing tool for functional and regression testing. It uses VBScript to specify test procedures and manipulate application objects.

QTP is primarily used for:

  • Automated Functional Testing: Automates user actions on applications to test various scenarios.
  • Regression Testing: Re-runs tests to ensure existing functionalities work with new changes.
  • Data-Driven Testing: Supports running tests with multiple data sets.
  • Integration with Test Management Tools: Integrates with tools like HP ALM for test management and reporting.

2. Explain the concept of an Object Repository.

An Object Repository in QTP is a collection of object descriptions used to identify and interact with application objects. There are two types:

  • Shared Object Repository (SOR): Used by multiple test scripts, promoting reusability and easier maintenance.
  • Local Object Repository (LOR): Specific to a single test script, useful for standalone tests.

Objects are identified based on properties like name and type. The repository stores these properties, allowing QTP to recognize objects during test execution.

3. How do you handle dynamic objects?

Dynamic objects in QTP have frequently changing properties, making them hard to identify with standard repositories. Descriptive programming allows you to specify property-value pairs directly in the script to identify these objects.

Example:

' Using descriptive programming to handle a dynamic button
Set btnDynamic = Browser("BrowserName").Page("PageName").WebButton("html tag:=INPUT", "type:=submit", "name:=btnSubmit")

' Perform an action on the dynamic button
btnDynamic.Click

This approach is useful when object properties change frequently.

4. Describe the different types of recording modes.

QTP offers three recording modes:

  1. Normal Recording Mode: The default mode, suitable for most needs, records actions by identifying objects and their properties.
  2. Analog Recording Mode: Records exact mouse and keyboard operations, useful for non-object level actions like drawing.
  3. Low-Level Recording Mode: Records exact x and y coordinates, used when QTP cannot identify objects.

5. How do you parameterize a test?

Parameterization in QTP allows test scripts to accept different data inputs, enhancing flexibility and reusability. Methods include:

  • Data Table Parameterization: Uses a built-in data table to define data sets.
  • Environment Variable Parameterization: Stores values accessible during execution.
  • Action Parameterization: Defines input and output parameters for actions.
  • Random Number Parameterization: Generates random numbers for input data.
  • Database Parameterization: Fetches data from a database for input.

6. Explain the use of checkpoints.

Checkpoints in QTP verify that the application functions as expected by comparing actual outcomes with expected ones. Types include:

  • Standard Checkpoint: Verifies object property values.
  • Bitmap Checkpoint: Compares images.
  • Text Checkpoint: Verifies text strings.
  • Database Checkpoint: Verifies database contents.
  • XML Checkpoint: Verifies XML data files or documents.

To implement a checkpoint, use the Checkpoint feature in QTP.

7. How do you handle exceptions?

In QTP, exceptions can be managed using Recovery Scenarios and VBScript’s error handling.

Recovery Scenarios define instructions to recover from unexpected events during test execution. They consist of Trigger Event, Recovery Steps, Post-Recovery Test Run, and Recovery Scenario Name.

VBScript’s error handling uses the On Error Resume Next statement to continue executing the next line of code when an error occurs. The Err object checks for errors and handles them.

Example:

' Enable error handling
On Error Resume Next

' Code that may cause an error
Set obj = CreateObject("NonExistent.Object")

' Check for errors
If Err.Number <> 0 Then
    ' Handle the error
    Reporter.ReportEvent micFail, "Error", "An error occurred: " & Err.Description
    ' Clear the error
    Err.Clear
End If

' Disable error handling
On Error GoTo 0

8. Explain the concept of Descriptive Programming.

Descriptive Programming in QTP allows specifying object properties and values directly in the script, bypassing the object repository. This is useful for dynamic objects.

Example:

' Using Descriptive Programming to click a button
Set objButton = Browser("title:=Google").Page("title:=Google").WebButton("name:=Google Search")
objButton.Click

9. How do you use Regular Expressions?

Regular expressions in QTP handle dynamic objects and text strings by defining a search pattern that can match multiple strings.

Example:

' Using regular expressions in QTP to identify a dynamic object
Set objDesc = Description.Create
objDesc("html tag").Value = "INPUT"
objDesc("name").Value = "user.*" ' Regular expression to match any name starting with "user"

Set obj = Browser("Browser").Page("Page").ChildObjects(objDesc)
If obj.Count > 0 Then
    obj(0).Set "example"
End If

The regular expression “user.*” matches any object whose name starts with “user.”

10. Explain the concept of Smart Identification.

Smart Identification in QTP identifies objects when recorded properties do not match during playback. It uses:

  1. Base Filter Properties: Fundamental properties that define the object type.
  2. Optional Filter Properties: Additional properties to narrow down object identification.

If QTP cannot identify the object using these properties, Smart Identification uses predefined properties.

11. How do you use Environment Variables?

Environment variables in QTP store values accessible throughout test scripts. They can be built-in or user-defined. Built-in variables provide information about the test environment, while user-defined variables store custom values.

Example:

' Accessing a built-in environment variable
Dim osName
osName = Environment.Value("OS")

' Creating and setting a user-defined environment variable
Environment.Value("URL") = "http://example.com"

' Accessing a user-defined environment variable
Dim url
url = Environment.Value("URL")

' Using the environment variable in a test step
Browser("Browser").Navigate url

12. Explain the concept of Keyword-Driven Testing.

Keyword-Driven Testing uses keywords to represent actions on the application under test. Components include:

  • Keywords: Actions like “Click” or “EnterText.”
  • Test Data: Data for executing the test.
  • Object Repository: Centralized storage for UI elements.
  • Driver Script: Executes actions based on keywords.

The driver script interprets keywords and interacts with the application.

13. What are the differences between QTP and Selenium?

QTP and Selenium are both automated testing tools with key differences:

  • Platform Support: QTP is for Windows applications, while Selenium supports multiple browsers and operating systems.
  • Programming Languages: QTP uses VBScript; Selenium supports multiple languages like Java, C#, and Python.
  • Cost: QTP is commercial; Selenium is open-source and free.
  • Integration: QTP integrates with HP products; Selenium integrates with various CI/CD tools.
  • Object Repository: QTP has a built-in repository; Selenium requires managing objects within scripts.
  • Community Support: Selenium has a large community; QTP support is through HP channels.

14. Describe the process of creating a shared object repository.

A shared object repository in QTP is a centralized storage for objects used across multiple test scripts. To create one:

  • Open QTP and navigate to the Resources menu.
  • Select Object Repository Manager.
  • Create a new shared object repository by selecting File > New.
  • Add objects using the Add Objects button.
  • Save the repository with a .tsr extension.

Associate the shared repository with test scripts via the Resources menu.

15. Write a script to create a custom function and call it within a test.

To create a custom function in QTP and call it within a test:

1. Define the function in a function library.
2. Associate the library with your test.
3. Call the function in your test.

Example:

' Define the custom function in a function library
Function AddNumbers(a, b)
    AddNumbers = a + b
End Function

' Save the above code in a file named "FunctionLibrary.vbs"

' In your QTP test, associate the function library
' Go to File -> Settings -> Resources -> Add the "FunctionLibrary.vbs" file

' Call the custom function within your test
Dim result
result = AddNumbers(5, 10)
MsgBox "The result is: " & result
Previous

10 Oracle RAC Interview Questions and Answers

Back to Interview
Next

10 SQL Server Reporting Service Interview Questions and Answers