IT Community - Software Programming, Web Development and Technical Support

QTP tips

This is a discussion on QTP tips within the Testing Tools forums, part of the Software Quality Assurance category; How do we associate a library file with a test ? " Library files are files containing normal VBScript code. The ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Quality Assurance > Testing Tools

Register FAQ Members List Calendar Mark Forums Read
  #141 (permalink)  
Old 11-23-2007, 02:10 AM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Post Re: QTP tips

How do we associate a library file with a test ?

" Library files are files containing normal VBScript code. The file can contain function, sub procedure, classes etc.... You can also use executefile function to include a file at run-time also. To associate a library file with your script go to Test->Settings... and add your library file to resources tab. "


- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #142 (permalink)  
Old 11-23-2007, 02:13 AM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Post Re: QTP tips

When to associate a library file with a test and when to use execute file?

" When we associate a library file with the test, then all the functions within that library are available to all the actions present in the test. But when we use Executefile function to load a library file, then the function are available in the action that called executefile. By associated a library to a test we share variables across action (global variables basically), using association also makes it possible to execute code as soon as the script runs because while loading the script on startup QTP executes all the code on the global scope. We can use executefile in a library file associated with the test to load dynamic files and they will be available to all the actions in the test. "


- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #143 (permalink)  
Old 11-23-2007, 02:23 AM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Post Re: QTP tips

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. "


- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #144 (permalink)  
Old 12-12-2007, 10:17 PM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Smile Re: QTP tips

What is VBScript?

> Based on the Visual Basic family of languages
> Supports object oriented features
> Interpreted
> Loosely Typed
> Syntax Rules

> VBScript is not case sensitive
> Each statement can only exist on one line
> Statements can be either simple statements or compound statements


- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #145 (permalink)  
Old 12-12-2007, 10:26 PM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Post Re: QTP tips

Naming Rules :

> Must begin with a letter or the underscore
> Good: count, strInfo, _data
> Bad: 2day, 4get, *count violate this rule.
> Cannot contain special characters except the underscore
> Good: Names using alphabets, numbers and the underscore.
> Bad: Names using symbols and other special characters.
> Cannot match a reserved word
> Bad: for, if, Select
> Must be unique within a context
> Must be less than 256 characters


- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #146 (permalink)  
Old 12-12-2007, 10:28 PM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Post Re: QTP tips

Naming Convention

objDescriptiveName

obj

Three letter prefix for the data type

DescriptiveName

> A descriptive name for the variable
> First letter of each word in upper case
> Literal Types

Numeric :

> 1
> 3.14
> 3E7

Boolean:

> True
> False
> Characters

“Hello World”
“123 Straw Lane”
“43210”

Date:

#07/21/2006#

- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #147 (permalink)  
Old 12-12-2007, 10:31 PM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Smile Re: QTP tips

Variables :

Dim variableName :

Variables hold values that can change during program execution
They function just like temporary storage locations
Constants:

Const constantName = value


Constant names hold values that cannot change during program execution

Constants should be used in place of hard-coded values

Operations
Operations are the many forms of computations, comparisons etc that can be performed in VB
Most operations are binary in the form:
operand1 operator operand2
Other operations are unary in the form
operator operand1
When an operator has 2 symbols, you cannot separate them with a space:
Good: 2 <> 3
Bad: 2 < > 3
Arithmetic
Used to perform calculations
Both operands must be numeric values
The result is a numeric value
+ Addition
- Subtraction, Negation
* Multiplication
/ Division
^ Exponent
Mod Modulo

- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #148 (permalink)  
Old 12-12-2007, 10:45 PM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Smile Re: QTP tips

Comparison:


Used to compare the value of two items
Both operands must be of the same data type
The result is a Boolean value

= Equality
<> Inequality
< Less than
> Greater than
<= Less than or equals
>= Greater than or equals


Logical



Used to reduce Boolean values into a single Boolean value
Both operands must be Boolean values
The result is a Boolean value
And Conjunction
Or Disjunction
Not Negation

<!--[if ppt]-->•<!--[endif]-->
And Truth Table:

Conjunction
Used when both conditions are required

- Vignesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #149 (permalink)  
Old 12-13-2007, 07:38 AM
sureshbb sureshbb is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 149
sureshbb is on a distinguished road
Default Re: QTP tips

What is a Recovery Scenario?

Recovery scenario gives you an option to take some action for recovering from a fatal error in the test. The error could range in from occasional to typical errors. Occasional error would be like "Out of paper" popup error while printing something and typical errors would be like "object is disabled" or "object not found". A test case have more then one scenario associated with it and also have the priority or order in which it should be checked.


Thanks
Suresh.B
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #150 (permalink)  
Old 12-13-2007, 07:38 AM
sureshbb sureshbb is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 149
sureshbb is on a distinguished road
Default Re: QTP tips

What does a Recovery Scenario consists of?

Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup window, any test error, particular state of an object or any application error.

Action: Action defines what needs to be done if scenario has been triggered. It can consist of a mouse/keyboard event, close application, call a recovery function defined in library file or restart windows. You can have a series of all the specified actions.

Post-recovery operation: Basically defined what need to be done after the recovery action has been taken. It could be to repeat the step, move to next step etc....

Thanks
Suresh.B
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #151 (permalink)  
Old 12-13-2007, 07:39 AM
sureshbb sureshbb is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 149
sureshbb is on a distinguished road
Default Re: QTP tips

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.

Thanks
Suresh.B
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #152 (permalink)  
Old 12-13-2007, 07:39 AM
sureshbb sureshbb is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 149
sureshbb is on a distinguished road
Default Re: QTP tips

How do we associate a library file with a test ?

Library files are files containing normal VBScript code. The file can contain function, sub procedure, classes etc.... You can also use executefile function to include a file at run-time also. To associate a library file with your script go to Test->Settings... and add your library file to resources tab.

Thanks
Suresh.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #153 (permalink)  
Old 12-13-2007, 07:40 AM
sureshbb sureshbb is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 149
sureshbb is on a distinguished road
Default Re: QTP tips

When to associate a library file with a test and when to use execute file?

When we associate a library file with the test, then all the functions within that library are available to all the actions present in the test. But when we use Executefile function to load a library file, then the function are available in the action that called executefile. By associated a library to a test we share variables across action (global variables basically), using association also makes it possible to execute code as soon as the script runs because while loading the script on startup QTP executes all the code on the global scope. We can use executefile in a library file associated with the test to load dynamic files and they will be available to all the actions in the test.

Thanks
Suresh.B
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #154 (permalink)  
Old 12-13-2007, 07:42 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Re: QTP tips

Test and Run-time Object



What is the difference between Test Objects and Run Time Objects ?

Test objects are basic and generic objects that QTP recognize. Run time object means the actual object to which a test object maps.



Can i change properties of a test object?

Yes. You can use SetTOProperty to change the test object properties. It is recommended that you switch off the Smart Identification for the object on which you use SetTOProperty function.



Can i change properties of a run time object?

No (but Yes also). You can use GetROProperty("outerText") to get the outerText of a object but there is no function like SetROProperty to change this property. But you can use WebElement().object.outerText="Something" to change the property.

Thanks
Sathian.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #155 (permalink)  
Old 12-13-2007, 07:43 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Re: QTP tips

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.

Thanks
Sathian.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #156 (permalink)  
Old 12-13-2007, 07:43 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Re: QTP tips

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.

Thanks
Sathian.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #157 (permalink)  
Old 12-13-2007, 07:44 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Re: QTP tips

What is checkpoint?

Checkpoint is basically a point in the test which validates for truthfulness of a specific things in the AUT. There are different types of checkpoints depending on the type of data that needs to be tested in the AUT. It can be text, image/bitmap, attributes, XML etc....

Thanks
Sathian.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #158 (permalink)  
Old 12-13-2007, 07:45 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Re: QTP tips

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.

Thanks
Sathian.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #159 (permalink)  
Old 09-29-2008, 06:56 AM
levelup levelup is offline
D-Web Trainee
 
Join Date: Sep 2008
Posts: 18
levelup is on a distinguished road
Default Re: QTP tips

Thanks for all your post, I have the same problem and now it has been sorted
__________________
business card printing
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:06 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0