Download presentation
Presentation is loading. Please wait.
1
Quick Test Professional Training Part 1
Neha Thakur Dec 02, 2010
2
Agenda Test Automation What & Why? QTP: An overview Intro to VBScript Language Data Types Algorithm Variables/Constants Operators Arrays Conditional Statements Loop Structures Best Scripting Practices
3
Test Automation Test Automation is the use of software to control the following: Test Creation Setting up Test preconditions Test Execution Comparison of actual v/s expected results Test Reporting functions In short, test automation is to automate the existing manual testing process as effectively and efficiently as possible
4
Test Automation Benefits
5
Test Automation Challenges
Maintainability: Automated test requires maintenance Skill-set: Creation of automation test suite requires skill sets such as knowledge programming language, testing tool etc Cost Benefits: The cost of automating the tests are sometimes more than manual Look & Feel verification: Difficult
6
QTP Overview Functional Testing Tool
An HP Product (Initially by Mercury Interactive) Support wide ranges of environment: Web, VB, JAVA, Oracle, SAP, ActiveX and many more Provide Expert and Keyword views Default Scripting language: VBScript
7
VBScript Option Explicit Algorithm
A pseudo code to solve a problem, which contains Initial Point Logic Steps (Instructions) End Point Problem: Add 2 numbers
8
VBScript Algorithm: AddNumbers Step#1: Input first number Step#2: Input second number Step#3: Add two numbers Step#4: Output the sum
9
VBScript Data Types VBScript supports only one data type called ‘Variant’. The variant data type is a special kind of data type that can contain different kinds of information . It is the default data type returned by all functions in VBScript. What are the values of c & d below?
10
VBScript Variables A variable is a placeholder that refers to a memory location that stores program information that may change at run time. A variable is referred to by its name for accessing the value stored or to modify its value. Public Statement Private Statement Dim Statement Note: Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure. Public statement variables are available to all procedures in all scripts. Private statement variables are available only to the script in which they are declared.
11
Working with constants
A constant is a variable within a program that never changes in value. Users can create their own constants by initializing variables accordingly and then not changing their value. VBScript defines the special True and False constants, as well.
12
Working with constants
Here are the various categories of constants provided in VBScript and a brief description of each: Color Constants - Defines eight basic colors that can be used in scripting. Date and Time Constants - Defines date and time constants used by various date and time functions. Date Format Constants - Defines constants used to format dates and times. Miscellaneous Constants - Defines constants that don't conveniently fit into any other category. MsgBox Constants - Defines constants used in the MsgBox function to describe button visibility, labeling, behavior, and return values. String Constants - Defines a variety of non-printable characters used in string manipulation. Tristate Constants - Defines constants used with functions that format numbers. VarType Constants - Defines the various Variant subtypes.
13
VBScript Constants A constant is a meaningful name that takes the place of a number or a string, and never changes. VBScript in itself has a number of defined intrinsic constants like vbOK, vbCancel, vbTrue, vbFalse and so on. Example: Const MY_STRING = "This is my string."Const MY_AGE = 49 Note: Standards can be defined to declare constants using only uppercase letters whereas all other variable are declared using first letter as smaller case.
14
VBScript Naming Convention
There are standard rules for naming variables in VBScript. A variable name: Must begin with an alphabetic character. Cannot contain an embedded period. Must not exceed 255 characters. Must be unique in the scope in which it is declared.
15
VBScript Operators Arithmetic Operators Comparison Operators
Description Symbol Addition + Subtraction - Multiplication * Division / Integer Division \ Exponentiation ^ Modulus arithmetic Mod Unary negation String concatenation & Description Symbol Equality = Inequality <> Less than < Greater than > Less than or equal to <= Greater than or equal to >= Object equivalence Is Logical Operators Description Symbol Logical negation Not Logical conjunction And Logical disjunction Or Logical exclusion Xor Logical equivalence Eqv Logical implication Imp
16
VBScript Conditional Constructs
Conditional Constructs execute statements or repeat certain set of statements based on conditions. The following conditional constructs are available in VBScript : If – Then –Else Select Case
17
Using Control Structures to Make Code Repeat
Looping allows you to run a group of statements repeatedly. Some loops repeat statements until a condition is False; others repeat statements until a condition is True. The following looping statements are available in VBScript: Do...Loop: Loops while or until a condition is True. While...Wend: Loops while a condition is True. For...Next: Uses a counter to run statements a specified number of times. For Each...Next: Repeats a group of statements for each item in a collection or each element of an array.
18
Using Control Structures to Make Code Repeat
Do code to execute Loop Until condition Loop While condition Do Until condition code to execute Loop Do While condition While condition [statements] Wend
19
Variable Naming Conventions
Subtype Prefix Example Boolean b bExist DateTime d dNow String s sName Object o oFile Integer, Byte, Long n (numeric) nCounter Single, Double f fPrice Error err errResponse Array arr arrLabels Currency c cDollar
20
Overriding Standard Variable Naming Conventions
You can override standard variable naming conventions by placing your variable name in brackets. This allows you to use reserved words or illegal characters in variable names. In a common usage, is not recommended to use this syntax. However, is possible.
21
Working with Arrays 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 you're storing sets of similar data because they often make it easier to manipulate the data together. Fixed Length Arrays Dynamic Arrays The benefit of a dynamic array is that if you don't know how large the array will be when you write the code, you can create code that sets or changes the size while the VBScript code is running. A dynamic array is created in the same way as a fixed array, but you don't put any bounds in the declaration. Eventually, you need to tell VBScript how many elements the array will contain. You can do this with the ReDim function. ReDim tells VBScript to "re-dimension“ the array to however many elements you specify. ReDim takes dimensions the same way Dim can.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.