Thursday, July 28, 2011

Sample Questions-Part 2-QTP

1) Which scripting language is used in QTP ?
  1.  Test Script Language (TSL)
  2.  Java Script
  3.  ASP
  4.  VB Script
2) Does QTP support Data Driven Framework ?
  1.  YES
  2.  QTP supports only Modular Framework
  3.  QTP is only Keyword Driven Framework
  4.  No


3) Select the Browsers NOT Supported by QTP ?
  1.  IE
  2.  Netscape
  3.  Safari
  4.  AOL

4) “Active Screen” Technology in QTP gives
  1.  Test Data
  2.  Checkpoints
  3.  Screenshots of Application Under Test (AUT)
  4.  Object Repository

5) Does the “Information” Toolbar in QTP 10.x give the Syntax Errors if any in the script ?
 YES
 NO
 It gives syntax errors only related to functions

6) Method to To count the no of rows in a table
 getrowcount
 getlinecount
 Getcount
 Count

7) Select Case statement is end with
 end case
 exit case
 esac
 end select

8) Object Repository is available in 3 modes viz.a) Per-Action Object Repository b) Shared Object Repository, c) Unshared Object Repository
 Both a & b
 Both a & c
 Both b & c
 Only a

9) What is the correct order of events in Test Script Creation ?
 Plan, Record , Debug, Enhance
 Plan , Record , Enhance , Debug
 Record, Debug , Plan , Enhance
 Record, Enhance, Debug , Plan

10) Which one is the default data type of QTP
 integer
 String
 Variant
 Double

11) To use the non-standard windows object, we can go for
 Object spy
 Virtual objects
 Object identification
 None

12) Select INVALID Checkpoint Type from the following
 Page Checkpoint
 Accessibility Checkpoint
 Object Checkpoint
 XML Checkpoint

13) To terminate the script execution, during running, QTP uses
 Exit run
 Stop run
 Quit
 None

14) BITMAP Checkpoint checks the property values of an image ?
 YES
 NO

15) Synchronization Point is used :-
 To delay QTP execution until Application Under Test (AUT) attains certain status
 To synchronize execution in multiple instances of QTP
 To synchronize per action and shared object repositories

16) Do statement always end with
 end while
 End do
 Wend
 Loop

17) By default a Datable contains :-
 One Action Sheet and One Global Sheet
 Two Global Sheets
 Two Action Sheets
 Two Action Sheets and One Global Sheet

18) Results Table (results of a test) is available in which following locations ?
 Test Script Folder
 Test Configuration Folder
 Test Results Folder
 Test Functions Folder

19) *.mts file contains :-
 Sequence and iterations of Actions to be executed
 User created library functions
 Per-Action Object Repository Files
 Parameter used in Actions

20) The feature of selecting different values of test data at run-time is called
 Synchronization
 Parameterization
 Smart Identification
 Transaction

21) Can Checkpoints be parameterized ?
 YES
 NO
 Maybe. Depends on the type of checkpoints

22) Can Test-Data in “Action Sheet” of Data Table be used from one action to another ?
 YES
 NO

23) Text Output Value -
a) outputs property value of any object
b) outputs text string appearing in AUT
c) outputs part of displayed text appearing in AUT
  
 only a
 only b
 only c
 both b & c

24) Select the valid types of Actions in QTP
a) Nested Actions
b) Shared Actions
c) External Actions
d) Reusable Actions
  
 both b & c
 both b & d
 both a & d
 both a & c

25) Can Actions inserted as “Call to Action” be modified by the test engineer?
 YES
 NO

26) Action Sheet (in Data Table) of an action inserted as “Copy of an Action” is editable only from the test from which they were created ?
 YES
 NO

27) Action Iteration is :-
 Number of times action would be executed every global iteration
 Number of time action would be executed in entire test execution
 Number of times all actions would be executed globally.

28) Choose the valid syntax to call Action 1 ( from Action 0) with input parameter “action_in” and store the output in a variable “MyVariable”
 RunAction 'Action1', oneIteration, Parameter(“action_in”), MyVariable
 RunAction 'Action0', oneIteration, Parameter(“action_in”), MyVariable
 RunAction 'Action1', oneIteration, MyVariable , Parameter(“action_in”)
 RunAction 'Action0', oneIteration, MyVariable , Parameter(“action_in

29) Can we use all standard Microsoft Excel features like Formulae, Formatting , Sorting etc in QTP DataTable ?
 YES
 NO

30) “Call to Copy” of an action can be inserted only for reusable actions ?
 NO
 YES

31) Parameterization of all Test data in a script can be done using
 Object Repository Manager
 Virtual Object Manager
 Data Driver
 Variable Driver

32) Are Nested Actions Call to one Action from Another ?
 YES
 NO

33) Is the Shared ( Global ) Action Repository the default repository in QTP ?
 YES
 NO

34) In a Per – Action (Local) Repository Action 1 and Action 2 in the same test script would have different object repositories?
 YES
 NO

35) The Share Action Repository is preferable when
 The Application Under Test is Dynamic with respect time
 The Application Under Test is Internet Environment
 The Application Under Test is Static

36) What is *.tsr file in QTP ?
 Object Repository Files
 VB Actions Files
 QTP Action Files
 Stores Test Data

37) Object Spy can be used to
 identify the Objects that can be identified by QTP
 identify the properties used for identification of objects
 identify the properties used for identification of objects in per-action repository
 identify the properties used for identification of objects in global action repository

38) Are Assistive properties used when mandatory properties are enough to identify an object ?
 YES
 NO

39) Are Ordinal Identifiers used when Mandatory and Assistive properties used by QTP are not enough to identify Object?
 YES
 NO

40) Select the Invalid type of Ordinal Identifiers Used by QTP
 Index Based
 Location based
 Creation Time
 Time Based

41) Does Index based ordinal identifier indicates the order in which the object appears in the parent window frame or dialog box relative to other objects?
 YES
 NO

42) Does Location based ordinal identifier indicates the order in which object appears in the application code relative to other objects?
 YES
 NO

43) Select the environments in which Creation Time ordinal identifier is used
 SAP
 Oracle
 Web
 Java

44) When a test is run in update mode, what is updated?
 The test results
 The object descriptions
 The action names in the test
 The logical names in the test

45) For identification of any object the choice of ordinal identifier selected can be modified in the Object Identification Window?
 YES
 NO

46) The Index Property value of Occurrence of the first object in source code is
 1
 a
 2
 0

47) Is Smart Identification is invoked when QTP cannot recognize an object using mandatory , assistive and ordinal properties ?
 Yes
 No
 Only in Web Environments

48) Select the type of properties used for Smart Identification
 Mandatory Properties
 Assistive Properties
 Base Filter Properties
 Smart Properties

49) Utility to measure the timing delays between transactions, we use
 synchronization
 sync
 services
 wait

50) Select the Invalid recording modes supported by QTP
 Low-level Recording mode
 Normal recording mode
 High-level Recording mode
 Analog recording mode

51) What does a breakpoint do?
 Stops test execution at the specified step, after executing that step
 Stops test execution at the specified step, before executing that step
 Pauses test execution at the specified step, after executing that step
 Pauses test execution at the specified step, before executing that step

52) Does Analog Recording mode, records exact mouse and keyboard operations ?
 YES
 NO

53) The RunAnalog function is used to run
 Tracks
 Functions
 Analog Functions
 Analog settings

54) Consider the QTP Script below
Window(“Calculator”).WinObject(“8”).Click 21,6
Window(“Calculator”).WinObject(“WinObject”).Click 14,13
In which mode is the script recorded ?
  Analog Recording mode
 Context Sensitive mode
 Low Level Recording mode

55) Virtual Objects are used when:-
 The objects do not exist in the Application Under Test
 Standard Objects cannot be recorded due to problems that arise during recording
 There are many objects of the same class in the Application Under Test

56) Consider the QTP Script below:-
On Error Resume Next
What does the above line of code do ?
  
 If an error occurs in the current line of script under execution , QTP proceeds ahead to the next step
 If an error occurs in the current iteration in script execution , QTP proceeds ahead to next iteration

57) Which of the following is an example of a missing resource?
 An object
 Run Results
 A Regular Action
 An External Action
58) To enter the non-executable statement in QTP , we use
 single quotes
 Rem
 double quotes
 Com

  

Tuesday, July 19, 2011

VB Script:QTP




As we all are aware that QTP supports VB script.
VB script: Basic
A variable is a virtual container in the computer's memory where we can store
Program information that may change during the time of our script is running.
In VBScript, variables are always of one fundamental data type, Variant.
A computer program can store information in a variable and then access that
Information later by referring to the variable's name.
Dim Statement
The Dim statement declares and allocates storage space in memory for
Variables. If the Dim statement is used at the start of a procedure then the variable is local to the procedure, if  it is used at start of a global script block the Dim will available throughout the module.
Syntax: Dim varname[([subscripts])][, varname[([subscripts])]]

Option Explicit Statement
Forces explicit declaration of all variables in a script.
If used, the Option Explicit statement must appear in a script before any other
statements. When you use the Option Explicit statement, you must explicitly
declare all variables using the Dim, Private, Public, or ReDim statements. If you
attempt to use an undeclared variable name, an error pop will appear displaying the message as “variable is undefined”

Arrays:
It is a variable which contains a series of variables value. Array variables and scalar variables are declared in the same way, except that the declaration of an array variable uses parentheses ( ) following the variable name. Arrays are useful when we are storing sets of similar data.

Constants 
A constant contains a value that never changes. For example, the value of PI is a constant. Use constants to define values that you know will never change during the execution of your script.VBScript also allows you to define your own constants.


Descriptive programming in QTP
Whenever QTP records any action on any object of an application, it adds some description on how to recognize that object to a repository of objects called object repository. QTP cannot take action on an object until unless its object description is in the Object Repository. But descriptive programming provides a way to perform action on objects which are not in Object repository.
Why to use Descriptive programming?
 Below are some of the situations when Descriptive Programming can be considered useful:
The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout <<UserName>>”.
When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object.
When you don’t want to use object repository at all. Well the first question would be why not Object repository? Consider the following scenario which would help understand why not Object repository
Scenario 1: Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing
Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page.Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.
When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.
How to use Descriptive programming:
There are two ways in which descriptive programming can be used
By creating properties collection object for the description.
By giving the description in form of the string arguments.By creating properties collection object for the description.To use this method you need first to create an empty description
Control Structures
Control structures allow you to control the flow of execution of your scripts. You can specify that some code should be executed only under certain circumstances, using conditional structures. You can specify that some code should be executed repeatedly, using looping structures. Lastly, you can specify that code from somewhere else in the script should be executed using branching structures.
Conditional Structures  
A)    If...Then...Else:
It allows you to choose which block of code to execute based on a condition or series of conditions.
If condition1 Then
  code block 1
ElseIf condition2 Then
  code block 2
Else
  code block 3
End If
If condition1 is True, code block 1 is executed. If it is False, and condition2 is True, code block 2 is executed. If condition1 and condition2 are False, code block 3 executes.
An If...Then construct may have zero or more ElseIf statements, and zero or one Else statements.
You can use NOT to reverse the logic of the IF structure. (i.e. If Not...Then...Else)
B)    Select Case:
It can be used instead of using some really complex If...Then constructs.
Select Case variable
Case chioce1
  code block 1
Case choice2
  code block 2
...
Case choiceN
  code block N
Case Else
  default code block
End Select
This compares the value of variable with choice1, choice2, and so on. If it finds a match, it executes the code block associated with that choice. If it does not find a match, it executes the default code block.
 Looping Structures
Looping structures allow you to execute the same block of code repeatedly. The number of times it executes may be fixed or may be based on one or more conditions. Be careful not to create an endless loop; that is one where the condition required to break the loop is never met.
 
A)    For...Next :
The looping structures take the following form:
For counter = start to s
  code block
Next
code block is executed with counter having the value start, then again with counter having the value start+1, then start+2, and so on until it has the value s. It then leaves the loop.
Optionally, you may specify a different value to increment counter by using this construct:
For counter = start to s Step stepvalue
  code block
Next
counter will take the values start+stepvalue, for example if stepvalue is 2 counter will count by 2s. If stepvalue is negative, s should be less than start.
B)    For Each...Next :
The loop use the following form:
For Each item In set
  code block
Next
code block is executed with item taking the value of each member of set. set should be an array or a collection.


C)    Do...While looping structure:
Do While booleanValue
  codeblock
Loop
code block is executed as long as booleanValue is True. If it is False to begin with, the loop is not executed at all.
D)    While...Wend looping structures have the following form :
while booleanValue
  code block
Wend
code block is executed as long as booleanValue is True. If it is False to begin with, the loop is not executed at all. Note: Wend is not supported in ASP.NET; use End While instead.
E)    Do...Loop While looping structure:
Do
  code block
Loop While booleanValue
code block is executed as long as booleanValue is True. The loop is executed at least once no matter what.
F)     Do Until...Loop looks like this:
Do Until booleanValue
  code block
Loop
code block is executed as long as booleanValue is False. If it is True to begin with, the loop is not executed at all.
G)    Do...Loop Until uses the following form:
Do
  code block
Loop Until booleanValue
code block is executed as long as booleanValue is False. The loop is executed at least once no matter what.

 Branching Structures:
  Branching structures allow you to jump from one position in the code to another.  
Subroutines:
It  do not return a value. They simply execute.
Sub name (argumentlist)
  code block
End Sub
Functions:
It return a value and have the following form:
Function name (argumentlist)
  code block
name = expression

End Function

QuickTest Professional Unplugged

Sample Questions in QTP

Sample Questions:


1. What does ChildObject Method Return
a. A Collection Object
b. A string true/false
c. A Boolean True/False
d. The Number of objects matching the child object descriptions
Ans: a

2. How can you make a test bypass the Object Repository during Test Run.
a. Turn the Object Repository Off
b. Use a programmatic Description
c. Delete all objects in all repositories
d. Add the Object in Object Repository Manager
Ans: b

3. When a test is run in Update mode, what options can you select? Select Three
a. the datatable
b. Check point properties
c. Test Object Description
d. Action Names in the test
e. Logical Names in the test
f. Active Screen Images and Values
Ans.C
4. What Object is used to read information from text file
a. Read
b. ReadLine
c. TextStream
d. FileStream
e. OpenTextFile
Ans.b

5. What can you use to handle unpredictable exceptions
a. A Do Loop
b. Recovery Scenario
c. If Then Else
d. Select Case Statemtn
Ans: b

6. You have just stopped recording steps into your tests. Your application under step is still up and visible on your screen. You now wish to add checkpoints into your test using the menu command, insert > Checkpoint from the toolbar. Which checkboxes are available to you? Select two
a. Text checkpoint
b. XML checkpoint
c. Bitmap checkpoint 
d. TextArea checkpoint
Ans:b
7. Browser Navigation Timeout is in which tab of Test Settings
a. Properties
b. Resources
c. Web
d. Web Settings
Ans: c

8. How many tabs are present in Test Settings (File > Settings) window
a. 7
b. 6
c. 5
d. 8
Ans: a

9. Identify the Tabs in the Test Settings (File > Settings) Window
a. Properties, Run, Resources, Parameters, Environment, Web, Recovery
b. Properties, Run, Resources, Parameters, Environment, Web Settings, Recovery
c. Properties, Run, Options, Parameters, Environment, Web, Recovery
d. Properties, Run, Resources, Input Parameters, Environment, Web, Recovery
Ans: a

10.'Generate Script' is in which tab of Test Settings (File > Settings) window
a. Properties
b. Web
c. Resources
d. Recovery
Ans: a

11. The following are the main columns in the Keyword view
a. Item, Operation, Value, Comments
b. Item, Operation, Value, Documentation
c. Item, Operation, Property, Documentation
d. Number, Operation, Value, Documentation
Ans: b

12. For each object and method in an Expert view statement, a corresponding row exists in the Keyword view
a. True
b. False
c. There is a problem with the statement
d. None of the above
Ans: a

13. You can work with one or several function libraries at the same time
a. True
b. False
Ans: a

14. You can insert additional steps on the test objects captured in the Active Screen after the recording session
a. True
b. False
Ans: a


15. Active screen enables you to parameterize object values and insert checkpoints
a. True
b. False
Ans: a

16. A QTP user can increase or decrease the active screen information saved with the test.
a. True
b. False
Ans: a

17. The information pane provides a list of ... in the test.
a. Semantic error
b. Syntax error
c. Common errors
d. Logical errors
Ans: b

18. When we switch from Expert view to Keyword view, QTP automatically checks for syntax errors and shows them in the information pane.
a. True
b. False
Ans: a

19. If the information pane is not open, QTP automatically opens it incase a syntax error is detected
a. True
b. False
Ans: a

Tuesday, July 12, 2011

Regular Expression in QTP

I found regular expression concept in QTPro is a very strong concept.I found it is very much helpful in web application.In web applicatiton the web object are changed dynamic.Now i am going to describe the regular expression.I found some useful content regarding the regular expression and their use while i was exploring some sites.
Regular Expression:
A regular expression is a formula for matching strings that follow some pattern.
In QuickTest Regular Expressions can be used in 3 places: 


1) Object Repository 
2) CheckPoints 
3) RegExp object.
Navigation through OR in QTP
·         Open the object repository
·         Select the desired object in the object hierarchy
·         Select the desired property in the properties list
·         Click on the constant value options button
·         Replace the constant value with suitable regular expression
·         Select the check box regular expression
·         Click on ok
·         Click on ok

           There's a good reason that regular expressions are found in so many diverse applications: they are extremely powerful. At a low level, a regular expression describes a chunk of text.
RegularExpression Cheat Sheet

Monday, July 11, 2011

Debugging

The following is the debugging process and the operational overview of the different step command available during debugging
Debugging:

Debugging is a process of executing the script or a program in a user desired passion with some temporary breaks in order to identify the errors.

To do the same QTP has provided step commands and break point feature.
Step commands: -
  1. Step into
  2. Step Out
  3. Step over


1. Step into:
Step into is used for executing a single statement then it will step in to the function or action and stops the execution.
2. Step Out:
Step out is used for executing all the remaining statements from the position of pointer in the function of the action and comes out of the function or action and stops execution
3. Step Over:
Step over is used for executing the single statement if that statement is a function call or action call then it will execute all the statements in side the function or action once and stops the execution

Break Point:
Break point is the feature provided by QTP, which is used for breaking the execution temporarily.

Debug viewer Pane:
Debug viewer pane is used for viewing, modifying or setting the currant value of the variables or expressions during the execution break with the help of three tabs by name

  1. Watch expressions
  2. Variables
  3. Command

Reporter utility object

Reporter utility object: -

It is used for reporting an user defined message to the result window

SYNTAX:
Reporter.Reportevent status,”object name”,”message”
Example: Reporter.Reportevent micdone,”my report”,”add button is working fine”.

Status:
Pass
0
Fail
1
Done
2
Warning
3


Transaction point in QTP

Transaction point:
 It is a concept introduced in QTP which is used for calculating the time taken by an application to perform a specific task or the execution time of a block of statement.

QTP has provided the following transaction options.
  1. Start transaction
  2. End transaction

Syntax:
Services.start transaction ”transaction name”
“ statement 1”
“ statement 2
Services.end transaction ”transaction name”

OUT PUT VALUE in QTP:

OUT PUT VALUE: -


Out put value is a feature provided by QTP, which is used for capturing a value from an application or from a database or from a XML file and stores it under specified column in the runtime data table


Operational overview of out put value: -
The out put value feature works in the following phases
  1. Pre-Execution Phase
  2. While –Execution Phase
1. Pre-Execution phase:
            It will capture the field name from which it need to capture the value
            It will generate the corresponding script
2. While-Execution phase:
            Captures the actual value from the field
            Stores it under a specified column in the run time data table

Out Put Values-
There are the following types of out put values

  • Standard Out Put Value: - It is used for capturing property value of a standard GUI object.
  • Text Out Put Value: - It is used for capturing the text present on a specified object
  • Text-Area Out Put Value: - It is used for capturing the Text present in a specified area
  • Data Base Out Put Value: - It is used for capturing a value from the database
  • XML Out put Value: - It is used for capturing a value from the XML file

Navigation for Standard Out put value through application:

  • Keep the cursor in the desired location
  • Keep the tool under recording mode
  • Activate the menu item insert
  • Go to out put value
  • Select the option standard out put value
  • Click on the desired object in the AUT
  • Click on OK
  • Select the desired property to be captured
  • Click on modify
  • Specify the desired column name
  • Click on Ok
  • Once again click on ok
  • Stop recording




Navigation For standard check point through Active Screen

  • Keep the cursor under the desired location
  • Click on active screen
  • Right click on desired location
  • Click on insert output value
  • Click on ok
  • Select the desired property
  • Click on modify
  • Specify the desired column name
  • Click on ok
  • Once again click on ok.

Data Driven Testing in QTP:

Data Driven Testing
                        Data driven testing is a concept introduced in the automation in order to implement re- testing.

Steps to be followed to perform data driven testing:
  • Collect the test data in to the data table
  • Generate the basic test
  • Parameterize the test
  • Execute the Test
  • Analyze the result

Parameterization:
                        Parameterization is a process of replacing the constant values with parameters or variables in order to increase the scope of the test. Parameterize can be done in three ways

  • Through data driver wizard
  • Through key word view
  • Manually

Navigation through Data Driver Wizard:

  • Activate the menu item tools
  • Select the option data driver
  • Click on parameterize
  • Click on next
  • Click on the parameter option button
  • Select the desired column name
  • Click on ok
  • Click on next
  • Click on finish
  • Finally click on ok

   Navigation Through Key word view:

  • Go to key word view
  • Select the desited constant value
  • Click on configure the value button
  • Select the option parameter
  • Select the desired column name
  • Click on ok





To avoid the above navigation one can directly type manually as follows:



A= datatable(“v1”,1)
Vbwindow(“form1”).vbedit(“val1”).set A
Vbwindow (“form1”).vbedit(“val2”).set datatable(“v2,1)
Vbwindow(“form1”).vbbutton(“Add”).Click
Vbwindow(“form1”).vbedit(“res”).check checkpoint(“RES”)
           
Navigation for parameterizing the check point:

  • Right click on the check point statement
  • Select the option check point properties
  • Select the option parameter
  • Click on the parameter options button
  • Select the desired column name
  • Click on ok
  • Once again click on ok
We can also parameter the test objects from object repository/object repository manager.