Introduction to vbscript basics for writing good qtp tests

Page 1

Introduction To VBScript Basics For Writing Good QTP Tests Today we will check out the essential VB scripting ideas. VB script is the language that QTP utilizes for its tests. While QTP is a significant easy to understand tool, it is imperative for the tester to have the capacity to have a fundamental programming skill utilizing VB Script to have the capacity to viably make, keep up and execute QTP tests. It ought to be noticed that this article is not a thorough rundown of all the VB Script highlights. Consider this as a place that will acquaint you with certain key ideas to guide you while you endeavor to self-take in the dialect. Since the master perspective of QTP is a VB Script proofreader, it is an unquestionable requirement that we attempt to comprehend VBscript for QTP before we proceed onward to our articles on QTP Expert View. It ought to be noticed that this article is not a thorough rundown of all the VB Script features. Consider this as a place that will acquaint you with certain key ideas to guide you while you endeavor to selflearn the language. Since the master perspective of QTP is a VB Script editor, it is an unquestionable requirement that we attempt to comprehend VBscript for QTP before we proceed onward to our articles on QTP Expert View. 1. Data types: There is just a single data type: Variant. It can store various types of information in view of the context in which it is utilized. If utilized as a part of a numeric setting it is a number or a string if utilized as a part of a string expression. If a number needs to carry on as a string we can put it in inside " ". There are different subtypes to a variant. You can expressly indicate these subtypes to accomplish a reasonable definition for your data. Functions to convert can be utilized to change over one subtype of data into another. Since it is the sole data type accessible, all the return values from a function are variants. 2. Constants: As the name suggests a constant is only a constant value in a program that is allocated a name. They can be pronounced by prefixing "Const" to a name. Eg: Const a="10" or Const Astr="Preeti". This value can't be changed inadvertently while the script is running.


3. Operators: Some of the major operators are as follows: - Equality (=) - Less than (<) - Greater than (>) - Logical negation (Not) - Logical conjunction (And) - Logical disjunction (Or) There are a few more as well. You can learn them while studying VB script. The rules for operator precedence are as follows: - Division or multiplication have higher precedence over addition or subtraction. - On the off chance that multiplication and division exist in a similar expression, then left to right precedence is considered - In the event that Addition and subtraction happen in the same expression,then as well, left to right is thought about. -The order can be superseded by utilizing brackets. For this situation, the expression inside the bracket is executed first. - & operator outweighs everything else after every single arithmetic operators and before every logical operators. 4. Variables: A variable is only a space in the PC's memory that can store certain data. This data will undoubtedly change every now and then. Where the information transfers physically is not a cause of concern, when required, it can be gotten to or changed by addressing to the name of the variable. - The data type of all variables is variant. - A variable can be or cannot be declared before its use. It is optional yet good to declare. Naming convention: Names must begin with an alphabetic character, must be unique, can't contain and implanted period and can't surpass 255 chars. A variable containing a solitary value is a scalar variable and the one that has more than one is an array.


A one dimensional Array can be proclaimed as: Dim A(10). All the arrays in VB Script are zero based that implies the array index begins from 0 through the number announced. That implies, our array A has 11 elements. Beginning from 0 to 10. To declare a 2 dimensional array, basically isolate the row count and column count by a comma. Eg: Dim A(5, 3). This implies it has 6 rows and 4 columns. The first number is dependably row and the second dependably a column. There is likewise a dynamic array whose size can change amid run time. These exhibits can be pronounced utilizing dim or redim statements. To conclude: Along these lines, this being the VBScript basics, in the future articles we will investigate how we can write a loop and conditional statements that are fundamental in building the programming logic.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.