Archive

Archive for the ‘QTP’ Category

File Handling Using QTP

QTP File Handling

Many times we have may need to interact with text files using QTP. Interaction can be (but not limited to) in the form of reading input from a file or writing output to a file.

We can use FSO (FileSystemObject) object to do this.

What is FSO?
FSO stands for File System Object. This is used to support text file creation and manipulation through the TextStream object and is contained in the Scripting type library (Scrrun.dll).
The FSO Object Model has a rich set of properties, methods and events to process folders and files.

How to create a file?
We first create a FSO object using CreateObject.

Secondly we create a text file using CreateTextFile.
For Example: Suppose you want to create a file called “test.txt” located in C:\

Dim fso, file, file_actual_location
file_ actual_location = “C:\file_ actual _location”
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set file = fso.CreateTextFile(file_ actual _location, True)

How to open a file?

Set file= fso.OpenTextFile(“C:\file_ actual_location”, ForWriting, True)
//2nd argument can be ForReading, ForWriting, ForAppending
//3rd argument is “True” if new file has to be created if the specified file doesn’t exist else false, blank signify false.

How to read content from a file?
Use ReadLine() method
For example:

Set file= fso.OpenTextFile(“C:\file_ actual_location”, ForReading, True) //2nd argument should always be “ForReading” in order to read contents from a file
Do while file.AtEndofStream <> True
data = file.ReadLine()
msgbox data
Loop

How to write content to a file?
You can use  Write() or WriteLine() Methods to write text into a file. The difference between the Write() and WriteLine() Method is that the latter automatically inserts a new line character while the former doesn’t insert a new line character.
For example:

Set file= fso.OpenTextFile(“C:\file_ actual_location”, ForWriting, True) //2nd argument should always be “ForWriting” in order to write contents to a file
file.Write(“This is test is”)
file.Write(“file created.”)
//Output will be:
This is test is file created.
while
file.WriteLine(“This is test is “)
file.Write(“file created.”)
//Output will be:
This is test is
file created.

How to delete file?
Use DeleteFile() method to delete a file from a particular location
Foe Example:

file_location = “C:\file_actual_location”
Set fso = CreateObject(“Scripting.FileSystemObject”)
fso.DeleteFile(file_ actual_location)

QTP Advantages and Disadvatages

Will be getting the initial focus on development of all new features and supported technologies.

  • Ease of use.
  • Simple interface.
  • Good error handling mechanism
  • Presents the test case as a business workflow to the tester (simpler to understand).
  • Excellent DDT (Data Driven Testing features)
  • Uses a real programming language (Microsoft’s VBScript) with numerous resources available.
  • Quick Test Professional 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.
  • Parametrization easier than WinRunner.
  • Can enhance existing QuickTest VB 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).
  • 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.
  • we can’t done merzeing easly, when compare to winrunner
  • we can’t able to check if the Window of Background colour is dynamically changes.

Some Useful Tips with QTP

We Sharing some of the useful tips on quick test professional. I used while working and found from gds (Project). I urge the readers to share their experiences/tips they have used while working on QTP. You can use the comments section to do the same.

1. How to add a constant number in a datatable?

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

2. How can i check if a parameter exists in DataTable or not?

The best way would be to use the below code:
on error resume next
val=DataTable(“ParamName”,dtGlobalSheet)
if err.number<> 0 then
‘Parameter does not exist
else
‘Parameter exists
end if

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

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

5. What is the difference between an Action and a function?

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

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

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

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

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

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

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

Environment.Value(“MyVariable“)=10
MyValue=Environment.Value(“MyVariable“)

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

File Name

Description

Type

Comments Regarding File

Test.tsp

Test settings

Binary

Do not edit

Default.xls

Data table parameters

Excel similar

Can be edited using Excel

Parameters.mtr

Parameterization information

Binary

Do not edit

Action

Action folder (See other table)

<!–[if !supportEmptyParas]–> <!–[endif]–>

<!–[if !supportEmptyParas]–> <!–[endif]–>

Default.cfg

Load test configuration file

Text

Do not edit

Default.prm

Load test configuration file

Text

Do not edit

Default.usp

Load test configuration file

Text

Do not edit

.usr

Load test configuration file

Text

Do not edit

Thick_usr.dat

Load test configuration file

Text

Do not edit

Thin_usr.dat

Load test configuration file

Text

Do not edit

Files within Action folder:

File Name

Description

Type

Comments Regarding File

Script.mts

Action script

Text

Edit text preceding the @@ sign only

Resource.mtr

Object Repository

Binary

Do not edit

Snapshots

Active screen files

Folder

Do not edit

There are few more files extensions like

.MTB Batch File
.LCK Locked

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

“The “” CheckPoint object was not found in the Object Repository. Check the Object Repository to confirm that the object exists or to find the correct name for the object.”

The CheckPoint object is not a visible object within the object repository, so if you manually modify the name, you may need to recreate the checkpoint to resolve the error.

11) Does QuickTest Professional support Internet Explorer 7.0?
QuickTest Professional 9.1
QuickTest Professional 9.1 supports Microsoft Internet Explorer 7.0 Beta 3. Internet Explorer version 7.0 is now certified to work and to be tested with QuickTest Professional version 9.1.
QuickTest Professional 9.0
QuickTest Professional 9.0 supports Internet Explorer 7.0 Beta 2.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not include support for Internet Explorer 7.0.

Does QuickTest Professional support Firefox?
QuickTest Professional 9.1 and 9.2
QuickTest Professional 9.1 provides replay support for Mozilla Firefox 1.5 and Mozilla Firefox 2.0 Alpha 3 (Alpha-level support for Bon Echo 2.0a3).
Notes:

QuickTest Professional 9.1 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.

The .Object property for web objects is not supported in FireFox.

QuickTest Professional 9.0
QuickTest Professional 9.0 provides replay support for Mozilla FireFox 1.5.
Notes:

QuickTest Professional 9.0 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.

The .Object property for web objects is not supported in FireFox.

QuickTest Professional 8.2 and below

QuickTest Professional 8.2 and below do not have support for Firefox.

12. Problem
After Quick Test Professional is started, Windows Media will not start. It returns the error message “wmplayer.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created.”
If you start Window’s Media Player first, it will continue to work normally after starting QuickTest Professional.
Solution:
Include the Windows Media Player’s executable in the NoBBTApps section of the mic.ini file.
1. Close QuickTest Professional.
2. Go to \bin\mic.ini.
3. Include wmplayer.exe in the NoBBTApps section of mic.ini file.

Example:
[NoBBTApps]
wmplayer.exe=rek
4. Save the mic.ini file and restart QuickTest Professional.

13. What is the lservrc file in QTP?
The lservrc file contains the license codes that have been installed
The lservrc file contains the license codes that have been installed. Whenever a new license is created, the license code is automatically added to this file. The lservrc file is a text file, with no extension.

File Location:

1. For a Concurrent (Floating) license installation:
#server installation directory#\#language#”

Example:
C:\Program Files\XYZ Technologies\ABC Server\English\lservrc
2. For a Seat (Stand-alone) license installation:
#AQT/QTP installation directory#\bin”

Example:
C:\Program Files\Mercury Interactive\QuickTest Professional\Bin\lservrc

14. What to do if you are not able to run QTP from quality center?
This is for especially for newbies with QTP.
Check that you have selected Allow other mercury products to run tests and components from Tools–> Options–> Run Tab.

15. Does QuickTest Professional support Macintosh operating systems?
No, QTP is not expected to run on this OS. Only on Windows.

Categories: QTP Tags: ,

QTP Interview Questions and Answers

QTP Interview Questions and Answers
******************

Full form of QTP ?

Quick Test Professional

What’s the QTP ?

QTP is Mercury Interactive Functional Testing Tool.

Which scripting language used by QTP ?

QTP uses VB scripting.

What’s the basic concept of QTP ?

QTP is based on two concept-
* Recording
* Playback

How many types of recording facility are available in QTP ?

QTP provides three types of recording methods-
* Context Recording (Normal)
* Analog Recording
* Low Level Recording

How many types of Parameters are available in QTP ?

QTP provides three types of Parameter-
* Method Argument
* Data Driven
* Dynamic

What’s the QTP testing process ?

QTP testing process consist of seven steps-
* Preparing to recoding
* Recording
* Enhancing your script
* Debugging
* Run
* Analyze
* Report Defects

What’s the Active Screen ?

It provides the snapshots of your application as it appeared when you performed a certain steps during recording session.

What’s the Test Pane ?

Test Pane contains Tree View and Expert View tabs.

What’s Data Table ?

It assists to you about parameterizing the test.

What’s the Test Tree ?

It provides graphical representation of your operations which you have performed with your application.

Which all environment QTP supports ?

ERP/ CRM
Java/ J2EE
VB, .NET
Multimedia, XML
Web Objects, ActiveX controls
SAP, Oracle, Siebel, PeopleSoft
Web Services, Terminal Emulator
IE, NN, AOL

How can you view the Test Tree ?

The Test Tree is displayed through Tree View tab.

What’s the Expert View ?

Expert View display the Test Script.

Which keyword used for Nornam Recording ?

F3

Which keyword used for run the test script ?

F5

Which keyword used for stop the recording ?

F4

Which keyword used for Analog Recording ?

Ctrl+Shift+F4

Which keyword used for Low Level Recording ?

Ctrl+Shift+F3

Which keyword used for switch between Tree View and Expert View ?

Ctrl+Tab

What’s the Transaction ?

You can measure how long it takes to run a section of your test by defining transactions.

Where you can view the results of the checkpoint ?

You can view the results of the checkpoints in the Test Result Window.

What’s the Standard Checkpoint ?

Standard Checkpoints checks the property value of an object in your application or web page.

Which environment are supported by Standard Checkpoint ?

Standard Checkpoint are supported for all add-in environments.

What’s the Image Checkpoint ?

Image Checkpoint check the value of an image in your application or web page.

Which environments are supported by Image Checkpoint ?

Image Checkpoint are supported only Web environment.

What’s the Bitmap Checkpoint ?

Bitmap Checkpoint checks the bitmap images in your web page or application.

Which enviornment are supported by Bitmap Checkpoints ?

Bitmap checkpoints are supported all add-in environment.

What’s the Table Checkpoints ?

Table Checkpoint checks the information with in a table.

Which environments are supported by Table Checkpoint ?

Table Checkpoints are supported only ActiveX environment.

What’s the Text Checkpoint ?

Text Checkpoint checks that a test string is displayed in the appropriate place in your application or on web page.

Which environment are supported by Test Checkpoint ?

Text Checkpoint are supported all add-in environments

Note:

* QTP records each steps you perform and generates a test tree and test script.

* QTP records in normal recording mode.

* If you are creating a test on web object, you can record your test on one browser and run it on another browser.

* Analog Recording and Low Level Recording require more disk sapce than normal recording mode.

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

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

How to handle the exceptions using recovery scenario manager in QTP?

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

What is the use of Text output value in QTP?

Output values enable to view the values that the application talks during run time. When parameterized, the values change for each iteration. Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.

How to use the Object spy in QTP 8.0 version?

There are two ways to Spy the objects in QTP: 1) Thru file toolbar, In the File Toolbar click on the last toolbar button (an icon showing a person with hat). 2) True Object repository Dialog, In Object repository dialog click on the button object spy. In the Object spy Dialog click on the button showing hand symbol. The pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object if at all the object is not visible. or window is minimized then, hold the Ctrl button and activate the required window to and release the Ctrl button.

How Does Run time data (Parameterization) is handled in QTP?

You can then enter test data into the Data Table, an integrated spreadsheet with the full functionality of Excel, to manipulate data sets and create multiple test iterations, without programming, to expand test case coverage. Data can be typed in or imported from databases, spreadsheets, or text files.

What is keyword view and Expert view in QTP?

Quick Test’s Keyword Driven approach, test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View. Advanced testers can view and edit their tests in the Expert View, which reveals the underlying industry-standard VBScript that Quick Test Professional automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.

Explain about the Test Fusion Report of QTP?

Once a tester has run a test, a Test Fusion report displays all aspects of the test run: a high-level results overview, an expandable Tree View of the test specifying exactly where application failures occurred, the test data used, application screen shots for every step that highlight any discrepancies, and detailed explanations of each checkpoint pass and failure. By combining Test Fusion reports with Quick Test Professional, you can share reports across an entire QA and development team.

Which environments does QTP support?

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

What is QTP?

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

Explain QTP Testing process?

Quick Test testing process consists of 6 main phases:

Create your test plan – Prior to automating there should be a detailed description of the test including the exact steps to follow, data to be input, and all items to be verified by the test. The verification information should include both data validations and existence or state verifications of objects in the application.

Recording a session on your application – As you navigate through your application, Quick Test graphically displays each step you perform in the form of a collapsible icon-based test tree. A step is any user action that causes or makes a change in your site, such as clicking a link or image, or entering data in a form.

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

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

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

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

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