Sunday, 30 August 2015

INTERVIEW QUESTIONS ON QTP

QTP 4 years real time interview quetions and answers:

1.How many types of Parameters are available in QuickTest Professional (QTP)?

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

2.When we try to use test run option "Run from Step", the browser is not launching automatically why?

This is default behaviour.
3. 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.
4. If I give some thousand tests to execute in 2 days what do you do?

Adhoc testing is done. It Covers the least basic functionalities to verify that the system is working fine.
5. How to "Turn Off" QTP results after running a Script?

Goto "Tools > Options > Run Tab" and Deselect "View results when run session ends". But this supresses only the result window, but a og will be created and can viewed manulaly which cannot be restricted from getting created.
6. Explain about the Test Fusion Report of QuickTest Professional (QTP) ?

Once a tester has run a test, a TestFusion report displays all aspects of the test run: a high-level results overview, an expandable Tree View of the test specifying exactly where application failures occurred, the test data used, application screen shots for every step that highlight any discrepancies, and detailed explanations of each checkpoint pass and failure. By combining TestFusion reports with QuickTest Professional, you can share reports across an entire QA and development team.
7. If an application name is changes frequently i.e while recording it has name “Window1” and then while running its “Windows2” in this case how does QTP handles?

QTP handles those situations using “Regular Expressions..
8. How to handle the exceptions using recovery secnario manager in QuickTest Professional (QTP)?

You can instruct QTP to recover unexpected events or errors that occured 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
9. What’s the basic concept of QuickTest Professional (QTP)?

QTP is based on two concept-
* Recording
* Playback.
10. Why use Regular Expressions?

you created a text checkpoint that searched for a specific text string. You can use regular expressions to increase the flexibility and adaptability of your tests.
Regular expressions enable QuickTest to identify objects and text strings with varying values. You can use regular expressions when defining the properties of an object, the methods of an argument, when parameterizing a step, and when creating checkpoints with varying values.

INTERVIEW QUESTIONS ON OBJECT REPOSITORY

Object Repository Interview Questions -QTP:

Define Object Repository in QTP.

Object Repository is used to store objects which QTP learns. Object repository stores things like logical name, properties (identification) etc. of an object.

Define Object Repository Manager.

Object Repository Manager enables you to create and modify single/multiple shared object repositories. You can save the shared object repository to your Quality Center project using the Object Repository Manager. Object Repository Manager helps you to Work with Repository Parameters, merge two Shared Object Repositories, import and export Shared Object Repositories using XML.

Can you export Local Objects to a Shared Object Repository using Object Repository Manager?

No, its done with the help of Object Repository Window.

What are the Drawbacks/Disadvantages of Shared Object Repository?

Multiple users working on Shared Object Repository can’t edit it concurrently.

Any small or big change in shared Object Repository affects all associated test cases.

There MAY be performance issue(s) if size of shared Object Repository is big. For example, if any object is vague / unclear then QTP has to assign some additional properties in order to recognize it uniquely and many other similar issues may slow down Object Repository performance.

Explain Object Repository parameter.

Repository parameters are useful when you want to create and run tests on an object that changes dynamically. As an example suppose there is a button whose text property value changes in a localized application depending on the language of the user interface. You can parameterize the name property value using a repository parameter, and then in each test that uses the shared object repository you can specify the location from which the property value should be taken. For example, in one test that uses this shared object repository you can specify that the property value comes from an environment variable.

In another test it can come from the data table. In a third test you can specify it as a constant value.

Can we update an Object Repository parameter at run-time?

You can set or retrieve the value of repository parameters using the Repository object [An object that enables you to work with repository parameters.]. All changes made to repository parameters using the Repository object are temporary, and are valid only for the current run session.

In order to set the value of a repository parameter use:

Repository (RepositoryParameterName) = NewValue

In order to retrieve the value of an existing repository parameter use:

CurrentValue = Repository (RepositoryParameterName)

How would you load an Object Repository at run time?

Using "Add" Method of RepositoriesCollection, as this adds an object repository file to the specified index position in the run-time collection of shared object repository files associated with the current action.

Syntax:
RepositoriesCollection.Add RepositoryPath [, Position]

RepositoryPath is the absolute or relative path of the shared object repository that you want to add and Position Number is the index position to which you want to add the shared object repository in the run-time list of associated shared object repositories. If you do not specify a position, the object repository is added to the end of the list (position = -1).

Explain kind of conflicts that occur when you try to merge two Shared Object Repositories?

An object in the primary object repository could have the same name as an object in the secondary object repository, but have a different description.

OBJECT IDENTIFICATION IN QTP

QTP : Object Identification

The process of uniquely identifying an object from the application window is known as Object Identification. QTP uses two modes object identification. to recognize the object uniquely.
  • Normal Identification mode
  • Smart Identification mode
  • Ordinal  Identifiers
Normal Identification
QTP has two lists of properties based on which it will identify the object uniquely. The first list is the list of mandatory properties. QTP learns these default property values and checks if any object matches the description. If no object in the application is identified uniquely it adds properties from the second list called as assistive properties. All the properties in the assistive list are added one by one till a unique object is identified.
 
 
Ordinal Identifiers
Even after using mandatory and assistive properties if the object is not uniquely identified then QTP uses the ordinal identifiers to identify the object uniquely.There are three types of ordinal identifiers :
  1. Index: This identifier indicates the order in which the object appears in the application code. This order is unique even though identical objects are present.
  2. Location: This identifier indicates the order in which the object appears within the window, frame or dialog box irrespective of objects with identical description.
  3. Creation Time: This identifier is applicable only to web applications. This identifier indicates a unique id in the order in which the browser were opened. This identifier is handy in identifying the browser to be worked on when a group of identical browsers are open.
Smart Identification
When normal identification fails to identify a unique object. QTP switches to next mode of identification called smart identification, the smart identification mode must be enabled for the test. The smart identification mechanism uses two lists of properties:
  • Base Filter Properties: The list of properties contain the most fundamental properties of a particular test object class whose values cannot be changed without changing the original object. 
  • Optional Filter Properties: Other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.

REGULAR EXPRESSION IN QTP

REGULAR EXPRESSION EXAMPLE

Regular Expressions
A regular expression is a special text string for describing a search for describing a search pattern. You can think of a regular expression as a wild card.You are probably familiar with wild card notations such as *.doc to find all word files in a file manager.


Grouping Regular ExpressionsMultiple Regular Expressions Characters can be combined in a Single Expression. For example :
Window("text:= .*(Report|Graph)").Close
The above line closes a window with Text Report or Graph preceded by any set of alphanumeric characters.

Using  the Backlash Character( \ )
The backlash can be used along with a Regular Expression Character to indicate that the next character be treated as a literal character. ex:-
Browser("Yahoo").Page("Yahoo").Link("text:= .*\..*").Click
Here the backlash is preceded by the .(period) so the .(period) will be considered literal & not a Regular Expression.

Regexp Object
You can use regular expressions in VBScript by creating one or more instances of the RegExp object. This object allows you to find regular expression matches in strings, and replace regexp matches in strings with other strings. You can create this object in scripting as shown below:
Regexp Rx = New Regexp

Automation Testing

QTP : Synchronisation

Sometimes scripts fail when they are run because of the speed mismatch between QTP and the application. QTP is always faster than the application as a result, the application responds to QTP slower than expected and the test fails. Instances where the application responds slower than expected and the test fails. These speed mismatch problems can be handled by synchronising the test. Synchronising the test involves making the QTP wait until the application is ready for performing the next step. 

Synchronising the Test

By modifying the default time settings for a test in QTP. QTP provides some setting for the test which makes QTP to wait for the mentioned time in the setting.
 
  1. Browser Navigation Timeout: This setting makes QTP wait for the web page to load completely for the specified amount of time. By default the maximum wait time specified by QTP is 60 seconds. This setting can further be modified bythe user based on his requirement. This setting is found in File>settings>Web>Browser navigation timeout. This setting is applicable only for web applications.
  2. Object synchronization timeout: This setting makes QTP wait for the specified amount of time for the objects to appear. By default the time setting is 20 seconds which can be modified by the user. these settings can be found in File>Setting>Run>Object synchronization timeout.
 
Wait/Exist statements 
These statements can be inserted to make QTP wait until an object exists.
Wait statement: When a wait statement is encountered, QTP pauses its script execution  for the specified amount of time. Once the specified amount is lapsed, QTP proceeds with the execution of next step.
Syntax: wait(n), where n is the number of seconds.

Exist statement: When a exist statement is inserted it checks if the object exists or not  in the application under test and returns a Boolean value for the same. Based on the return value, appropriated steps can be taken to handle the timing mismatch.You can combine wait and exist statements within a loop to instruct QTP to wait until the objects exists before continuing with the test.

Inserting Synchronization Point
 
A synchronization point can be inserted which makes QTP pause the test until an object property achieves a specified value. Synchronization point is often referred to as intelligent wait statement. Steps to insert a synchronization point are given below:
 
  1. Start a recording session. Select Insert>Synchronization Point.
  2. Click the object in your application for which you want to insert a synchronization point.
  3. Select the object for which you want to insert a synchronization point and click OK.

                     
  4. The Add Synchronization Point dialog box opens as shown in figure below:

                     
  5. Enter all the required values in Add Synchronization Point dialog and click OK. A WaitProperty step is added to the Test.
 

What is Synchronization?

 Synchronization point is the time interface between Tool and Application under test. Synchronization point is a feature to specify delay time between one step and another of the test script.
 For Example, clicking on a link may load the page is 1 second, sometimes 5 seconds or even it might take 10 seconds to load it completely. It depends on various factors such as the application server response time, network bandwidth , client system capabilities etc. 
 If the time is varying then the script will fail unless the tester handles these time differences intelligently.
 

Ways to Insert Sync Point:

 
 
 
 
 
 Let us say we need to insert a sync point beween clicking on "numbers" link and clicking on "simple Interest" calculator of in "http://easycalculation.com/". We will now take a look at all the 5 ways to insert sync point for the above scenario.
 

Method 1: WaitProperty

 WaitProperty is a method that takes the property name, Value and Timeout value as input to perform the sync. It is a dynamic wait and hence this option is encouraged.
 
' Method 1 - WaitProperty with 25 seconds
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click
 
obj.Link("Simple Interest").WaitProperty "text", "Simple Interest",25000
obj.Link("Simple Interest").Click
 

Method 2: Exist

 Exist is a method that takes the Timeout value as input to perform the sync. Again it is a dynamic wait and hence this option is encouraged.
 
' Method 2 : Exist Timeout - 30 Seconds
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click
 
If obj.Link("Simple Interest").Exist(30) Then
        obj.Link("Simple Interest").Click
Else
        Print "Link NOT Available"
End IF
 

Method 3: Wait

 Wait is a hardcoded sync point which waits independent of the event happened or NOT. Hence usage of Wait is discouraged and can be used for shorter wait time such as 1 or 2 seconds.
 
' Method 3 : Wait Timeout - 30 Seconds
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click
wait(30)
Browser("Math Calculator").Page("Math Calculator").Link("Simple Interest").Click
 

Method 4: Sync Method

 Sync Method can be used only for web applications where there is always a lag between page loads.
 
' Method 4 : 
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click
 
Browser("Math Calculator").Sync
Browser("Math Calculator").Page("Math Calculator").Link("Simple Interest").Click
 

Method 5 : Inserting QTP Inbuilt Synchronization points:

 Step 1 : Get into Recording Mode. This Option Would be Disabled if the user is NOT in Recording Mode.
 Step 2 : Goto "Design" -> "Synchronization Point" .
 Step 3 : We need to Select the object which we want to be the Sync Point. After Selecting the object, object window opens as shown below:
 
 Step 4 : Click Ok, the "Add Synchronization Window" Opens up. Select the Property, Value and Time out value and click ok as shown below:
 
 Step 5 : The Script would be generated as shown below which is the same as that of the WaitProperty(Method 1) that we had already discussed:
 
Browser("Math Calculator").Page("Math Calculator").Link("Numbers").Click
Browser("Math Calculator").Page("Math Calculator").Link("Simple Interest").WaitProperty "text", "Simple Interest", 10000
 

Default Synchronization:

 When user hasn't used any of the above sync methods, still QTP has inbuild Object synchronization timeout which can be adjusted by the user.
 Navigate to "File" >> "Settings" >> Run Tab >> Object Synchronization Time out as shown below.
 

Automation Testing

QTP - Interview Questions for 3 years exerienced candidates


Q. 11: What is a Virtual Object in QTP?
===============================
Since sometimes complex objects are not recognized & recorded properly by QTP. Hence an experienced user can define that object as a personal virtual object and build a virtual object repository. This way by the concept of Virtual Object, the user can add some sort of support for such complex objects.
If it is possible to extract the desired information from the object, we can do successful record and playback against that object.
=================================
Q. 12: How results are generated in QTP?
=================================
At the end of the test, QTP generates a result file for the test cases, which is in the form of a XML tree.
This results file provides detail regarding 'Pass' or 'Fail' counts, error messages, and all supporting information which allows the user to diagnose the main cause of a failure.
===================================================
Q. 13: How many types of main views of a script are available in QTP?
===================================================
QTP provides two main views of a script. These are
1) Keyword View: is the default test procedure interface of QTP & is most useful for the beginners. It displays the automation steps of a test procedure as a descriptive tree of Actions and functions. The tree contains columns listing the Action or function name, any parameters, and comments.
2) Expert View: is most suitable for the advanced users, enabling them to customize the test, like writing user-defined functions. It is meant for displaying and editing of the source code of the test. Except for the root Global action, all other test actions can be edited here. Expert View acts as an IDE for the test. It includes most standard IDE features, such as breakpoints.
Both Keyword View & the Expert View can be selected from tabs available at the bottom of the QTP window.
=======================
Q. 14: What is a Checkpoint?
=======================
In QTP, Checkpoint is used to verify the application under test. It can introduce a checkpoint to verify as to whether a particular object, text or a bitmap is present in the automation run.
During a test execution, a checkpoint verifies that the behavior or state of the actual application is consistent with the expected application or not.
===============================================
Q. 15: How many types of Checkpoints are available in QTP
===============================================
1) Standard Checkpoint - for checking the properties of an object.
2) Table Checkpoint - for checking the properties of a table.
3) Image Checkpoint - for checking the properties of an image.
4) Bitmap Checkpoint - for comparing an area of the application under test pixel-by-pixel with the screen as seen at record-time.
5) Database Checkpoint - for automating the back-end testing.
6) Text Checkpoint - for checking that a section of text is found between two other sections of text.
7) Text Area Checkpoint
8) Page Checkpoint - for checking the properties of a web page.
9) Accessibility Checkpoint - for checking the accessibility of an application.
10) XML Checkpoint
========================================
Q. 16: What is the use of Text output value in QTP?
========================================
Text Output values enable us to view the values which are taken by the application during the run time. If parameterized, the values change for every iteration. Hence by creating output values, we can capture the values which are taken by the application during the run time and output them to the data table.
=================================================
Q. 17: What's the difference between a Checkpoint and Output Value?
=================================================
Checkpoint only checks for the specific attribute of an object in AUT while Output value can output those attributes value to a column in data table.
==================================================
Q. 18: How can we Disable Smart Identification During the Run Session?
==================================================
Selection of the option "Disable Smart Identification during the run session", Instructs QTP not to use the Smart Identification mechanism during the run session.
When we select this option, the Enable Smart Identification check boxes in the Object Properties and Object Repository dialog boxes get disabled, although the settings are saved. However when you clear this option, the Enable Smart Identification check boxes return to their previous on or off setting.
=====================================================
Q. 19: What are the Properties used by Smart Identification Feature of QTP?
=====================================================
1) Base filter properties: Are the most fundamental properties of a particular test object class. Her we can not change their values without changing the essence of the original object.
2) Optional filter properties: Are other properties, which help us in identifying the objects of a particular class since these are not likely to get changed frequently. These properties can be ignored in case these are not applicable any more.
====================================================
Q. 20: How can we check if an environment variable exists or not?
====================================================
When we use Environment("Param1").value then QTP expects the environment variable to be already defined. But when we use Environment.value("Param1") then QTP will create a new internal environment variable if it does not exists already. So to be sure that variable exist in the environment try using Environment("Param1").value.


QTP - Interview Questions : Part 1


Q. 1: What is Automation Object Model in QTP?
======================================
Like we use QTP for automating the testing of our applications, we can use the automation object model of QTP to automate its own operations as well. With the help of objects, methods, and properties exposed by the automation object model of QTP along with standard programming elements like loops and conditional statements, we can write programs which can configure QTP options and run tests or components instead of performing these operations manually using the QTP interface.
Automation programs are especially useful for performing the same tasks several times or on multiple tests or components, or quickly configuring QTP according to the needs for a particular environment or application.
Most of the dialog boxes in QTP have a corresponding automation object. Most of the options in dialog boxes can be set retrieved using the corresponding object property, and most of the menu commands and other operations have corresponding automation methods.
============================
Q. 2: What is a Recovery Scenario?
============================
Recovery scenario gives you an option to take some action for recovering from a fatal error in the test. Such problems are quite frequent especially when the tests are made to run unattended. In such a case the test process halts until the user perform some desired recovery operation.
Recovery scenarios are useful when it is difficult to predict at which step the errors can come or when we are confident that the error will not come in the QTP script, whereas it can be anywhere outside the QTP Script. For illustration; Pop-up message of "out of paper", as caused by the printer device driver. "On error resume next" is preferred when we sure that the error is expected one and wish to perform some other actions.
=================================
Q. 3: What is Smart Identification in QTP?
=================================
QTP has a unique feature by the name Smart Object Identification or recognition which is used for identifying the objects smartly, whenever the normal identification fails due to the dynamic changes in the properties of the objects.
Smart Identification is nothing but an algorithm used by the QTP when it is not able to recognize an object.
=================================
Q. 4: How QTP identifies various Objects?
=================================
During recording QTP identifies various objects and stores them as test objects. For each test object QTP learns a set of default properties called mandatory properties. Simultaneously QTP looks at rest of the objects to check whether these properties are sufficient to uniquely identify the object or not. During the test run, QTP searches for the run time objects, which match with the test objects which, have been captured by it during recording.
==================================
Q. 5: What are Object Repositories in QTP?
==================================
When planning and creation of tests is done, we firstly consider how we would like to store the objects in our tests. In QTP, the test objects can be stored in two types of object repositories
a) Shared object repository: It stores test objects in a file that can be accessed by multiple tests (in read-only mode). If someone is new to QTP, he can prefer to use local object repositories. This way he can record and run the tests without creating, choosing, or modifying shared object repositories because all objects are automatically getting saved in a local object repository which can be accessed by its corresponding action.
b) Local object repository: It stores objects in a file that is associated with one specific action, so that only that action can access the stored objects. If someone is familiar with QTP testing, he can find that it is quite efficient to save the objects in a shared object repository. This way, he can use the same shared object repository for multiple actions - if the actions include the same objects. Test object information that applies to many actions is kept in one centralized location. When the objects in the application change, we can update them in one location for all the actions that use this shared object repository.
==============================================
Q. 6: How QTP recognizes objects in Object Repositories?
==============================================
Object Repository displays a tree of all the objects in the current component or in the current action or in the entire test , depending on the object repository mode selected by the user. 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 remembers the default property values and determines in which test object class it fits. If it is not found enough it automatically adds assistive properties, one by one to the description until it successfully compiles the unique description. If no assistive properties are available, then it adds a special Ordinal identifier such as object location on the page or in the source code.
========================================
Q. 7: How many types of Actions are there in QTP?
========================================
QTP uses following three kinds of actions:
a) Non-reusable action - can be called only in the test with which it is stored, and can be called only once.
b) Reusable action - can be called multiple times by the test with which it is stored (the local test) as well as by other tests.
c) External action - is a reusable action which is stored with another test. External actions are read-only in the calling test, but we can choose to use a local, editable copy of the Data Table information for the external action.
By default, all new actions are non-reusable. We can mark every action created by us in the test as reusable or non-reusable.
===========================================
Q. 8: 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. Step Generator utility enables us to add steps by selecting from a range of context-sensitive options and entering the required values.
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.
Method to open the Step Generator from a function library is as under
a) In the function library, click the location in which you want to insert the new step.
b) Choose Insert > Step Generator, or right-click and choose Step Generator. Alternatively, press F7.
====================================
Q. 9: What is a Run-Time Data Table in QTP?
====================================
During the run session, QTP creates a Runtime Data Table, which is live version of the Data Table associated with our test. During the run session, QTP displays the run-time data in the Data Table pane so that we can see the changes taking place in the Data Table.
When the run session ends, the Runtime 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 does not get saved along with the test. The final data from the run-time Data Table gets displayed in the Run-Time Data Table in the Test Results window.
Runtime Data Table is an excel file, which gets stored in the folder of the test created, its name is Default.xls by default.
====================================
Q. 10: What is the Object Spy feature in QTP?
====================================
Using the Object Spy pointing hand mechanism, you can view the supported properties and methods of any object in an open application. As you move the pointing hand over the objects in the application, their details are displayed in the Object Spy. These details may include the test object's hierarchy tree, its properties and values, and the methods associated with the object. For methods, the syntax is also displayed.