VBScript Tutorial for UFT
I) Introducing VBScript:
> Visual Basic Scripting Edition, It is a calorie-free weight linguistic communication from Microsoft.
> VBScript derived from VB Programming language.
> VBScript is non a instance sensitive language.
> No formalities for writing statements.
> It ignores extra spaces.
> It is a platform subject language.
----------------------------------------
II) Scripting Languages versus Programming Languages
a) Scripting Languages:
Example: Shell script, Perl, Java Script, Python, Ruby, Rexx etc...
> No Explicit proclamation of Data Types, Ex: Dim a, b, c
> Scripting Languages are Interpreter based languages.
> Scripting Languages back upwardly Explicit too Implicit proclamation of Variables.
Example:
Dim a
a = 100 'Explicit variable
b = 200 'Implicit variable
Msgbox a + b
> Limited Support for Application development
> Limited back upwardly for UI design.
> Limited back upwardly for graphics design.
> Scripting Languages Can live on easily integrated amongst other Technologies.
> Scripting Languages Reduce the code size
----------------
b) Programming Languages:
Example: COBOL, C, C++, Java, VB, VC++, C# etc....
> Programming Languages back upwardly Explicit Declaration of Data types only.
Example:
int a, char b, float c
> Programming Languages are Compiler based Languages.
> Programming Languages back upwardly Explicit proclamation of Variables only.
> Rich back upwardly for Application development.
> Rich back upwardly for UI design.
> Rich back upwardly for Graphics design.
> Difficult to integrate amongst other technologies.
> Scripting Languages Increase the code size.
-------------------------------------------------------------
III) Usage of VBScript
a) Client side scripting inwards the Web (HTML) (Browser-IE)
b) Server side scripting inwards the spider web (ASP) (Web Server -IIS)
c) Network Administration on Server OS (WSH)
d) System Administration on Client OS or Server OS (WSH)
---------------------------------------
e) Test Automation (UFT) (UFT)
-------------------------------------------
IV) VBScript Fundamentals too Features
1) Adding Comments
Purpose:
To brand the code Readable
To brand the code disable from Execution
------------------------------------
2) Data Types
> No Data type specification inwards VBScript
> VBScript considers information sub types based on usage of the Data
> using VarType business office user tin cheque the information sub types.
----------------------------------------------------
3) Declarations
a) Constants
Built in
User defined
b) Variables
Scalar Variables
Array variables
* Dictionary object is equilent to Hash variables/ Associated Arrays inwards Perl Script.
------------------------------------------
4) Operators
Categories of Operators
a) Arithmetic operators
b) Comparison operators
c) Logical operators
----------------
* Concatenation operators (Part of Arithmetic operators)
------------------------------------------------------
5) Conditional Statements
a) Types of conditional statements
i) If statement
ii) Select Case statement
--------------
b) Types of conditions
i) Single condition
ii) Compound condition
iii) Nested condition
-----------------------------
c) Usage of Conditional statements
i) Execute a disceptation when status is truthful / unproblematic if
ii) Execute a block of statements when status True.
iii) Execute a block of statements when status True, otherwise execute roughly other block
of statements.
iv) Decide amid several alternates (Elseif)
v) Execute a block of statements when to a greater extent than than ane status is True (Nested If)
vi) Decide amid several alternates (Using pick out Case)
------------------
d) Purpose of Conditional statements inwards UFT
i) To insert verification points
ii) Error handling
--------------------------------------------------------
6) Loop Statements
a) For...Next
b) While...Wend
c) Do While / Until...Loop
d) For Each...Next
* Using Exit Statement nosotros tin give the sack the loops.
Note: nosotros tin insert Loop statements inside weather too vice versa
----------------------------------------------
7) VBScript Functions
> Function is a Reusable code.
> Whenever nosotros desire execute same operations multiple times therefore nosotros prefer functions.
Types of functions
a) Built-in Functions
i) Array Functions
ii) String functions
iii) Date & Time functions
iv) Conversion functions
v) I/O Functions
vi) Math Functions
vii) Miscellaneous functions
b) User defined Functions
--------------------------
i) Sub Procedures
Public, Private - Access control
Internal, External - Usage
ii) Function Procedures
Public, Private - Access control
Internal, External - Usage
---------------------------------------------------
8) Coding conventions
Writing comments
Naming conventions etc...
ex:
Dim num, city, Fso 'Without standards
Dim intNum, strCity, objFso -With naming standards
------------------------------------------------------
9) File System Operations
> What is Computer File System?
> Examples for File System Operations
> How halt user performs File System Operations
> How to perform automatic File System Operations
Using File System Object nosotros tin perform automatic File System Operations
Class value for creating File System Object - ("Scripting.FileSystemObject")
Set Variable = CreateObject("Scripting.FileSystemObject")
Set is VBScript statement
CreateObject is Built function
---------------------------------------------
10) Excel Application Operations
Excel Application Object:
It is used to perform operations on Excel Application/Excel files
Class Value for creating Excel Application object - ("Excel.Application")
-----------------------------------------------
11) Word Application operations
Word Application Object
It is used to perform operations on Word Application / Word documents.
Class value for creating Word Application object - ("Word.Application")
-----------------------------------------------------
12) Database operations
a) Database Connection Object
It is used to connect to Databases
Note: Connection string entirely varies from One Database to another.
Class value for creating database connective object - ("Adodb.Connection")
----------
b) Database Recordset Object
It is used to perform operations on Database Records.
Class value for creating Database Recordset object - ("Adodb.Recordset")
----------------------------------------------
13) Dictionary Object
It is used to define key, value pairs.
Class value - ("Scripting.Dictionary")
------------------------------------------------------------
14) Regular Expressions
Regular Expression - It is a formula for matching patterns
Constant matching -
india.doc - india.doc
Pattern matching
i*.
ia.....
ib..........
.
.
india.doc
-------------------------------------------------------
15) Error Handling
Handling expected too unexpected Errors.
Expected Error:
Whenever nosotros exercise invalid input therefore nosotros tin await the Error.
Note: We exercise Invalid Input for Negative Testing
----------------
Unexpected Error:
Scenarios:
i) Availability of the Resource
ii) Resource Response
iii) Insufficient Resource.
------------------------------
VBScript features for Error Handling:
a) Conditional statements
b) Using roughly built inwards Functions
c) Using Exit Statement
d) Using Option explicit disceptation
e) Using On fault Resume Next
Etc...
-----------------------------------------------
I) Introducing VBScript:
> Visual Basic Scripting Edition, It is a calorie-free weight linguistic communication from Microsoft.
> VBScript derived from VB Programming language.
> VBScript is non a instance sensitive language.
> No formalities for writing statements.
> It ignores extra spaces.
> It is a platform subject language.
----------------------------------------
II) Scripting Languages versus Programming Languages
a) Scripting Languages:
Example: Shell script, Perl, Java Script, Python, Ruby, Rexx etc...
> No Explicit proclamation of Data Types, Ex: Dim a, b, c
> Scripting Languages are Interpreter based languages.
> Scripting Languages back upwardly Explicit too Implicit proclamation of Variables.
Example:
Dim a
a = 100 'Explicit variable
b = 200 'Implicit variable
Msgbox a + b
> Limited Support for Application development
> Limited back upwardly for UI design.
> Limited back upwardly for graphics design.
> Scripting Languages Can live on easily integrated amongst other Technologies.
> Scripting Languages Reduce the code size
----------------
b) Programming Languages:
Example: COBOL, C, C++, Java, VB, VC++, C# etc....
> Programming Languages back upwardly Explicit Declaration of Data types only.
Example:
int a, char b, float c
> Programming Languages are Compiler based Languages.
> Programming Languages back upwardly Explicit proclamation of Variables only.
> Rich back upwardly for Application development.
> Rich back upwardly for UI design.
> Rich back upwardly for Graphics design.
> Difficult to integrate amongst other technologies.
> Scripting Languages Increase the code size.
-------------------------------------------------------------
III) Usage of VBScript
a) Client side scripting inwards the Web (HTML) (Browser-IE)
b) Server side scripting inwards the spider web (ASP) (Web Server -IIS)
c) Network Administration on Server OS (WSH)
d) System Administration on Client OS or Server OS (WSH)
---------------------------------------
e) Test Automation (UFT) (UFT)
-------------------------------------------
IV) VBScript Fundamentals too Features
1) Adding Comments
Purpose:
To brand the code Readable
To brand the code disable from Execution
------------------------------------
2) Data Types
> No Data type specification inwards VBScript
> VBScript considers information sub types based on usage of the Data
> using VarType business office user tin cheque the information sub types.
----------------------------------------------------
3) Declarations
a) Constants
Built in
User defined
b) Variables
Scalar Variables
Array variables
* Dictionary object is equilent to Hash variables/ Associated Arrays inwards Perl Script.
------------------------------------------
4) Operators
Categories of Operators
a) Arithmetic operators
b) Comparison operators
c) Logical operators
----------------
* Concatenation operators (Part of Arithmetic operators)
------------------------------------------------------
5) Conditional Statements
a) Types of conditional statements
i) If statement
ii) Select Case statement
--------------
b) Types of conditions
i) Single condition
ii) Compound condition
iii) Nested condition
-----------------------------
c) Usage of Conditional statements
i) Execute a disceptation when status is truthful / unproblematic if
ii) Execute a block of statements when status True.
iii) Execute a block of statements when status True, otherwise execute roughly other block
of statements.
iv) Decide amid several alternates (Elseif)
v) Execute a block of statements when to a greater extent than than ane status is True (Nested If)
vi) Decide amid several alternates (Using pick out Case)
------------------
d) Purpose of Conditional statements inwards UFT
i) To insert verification points
ii) Error handling
--------------------------------------------------------
6) Loop Statements
a) For...Next
b) While...Wend
c) Do While / Until...Loop
d) For Each...Next
* Using Exit Statement nosotros tin give the sack the loops.
Note: nosotros tin insert Loop statements inside weather too vice versa
----------------------------------------------
7) VBScript Functions
> Function is a Reusable code.
> Whenever nosotros desire execute same operations multiple times therefore nosotros prefer functions.
Types of functions
a) Built-in Functions
i) Array Functions
ii) String functions
iii) Date & Time functions
iv) Conversion functions
v) I/O Functions
vi) Math Functions
vii) Miscellaneous functions
b) User defined Functions
--------------------------
i) Sub Procedures
Public, Private - Access control
Internal, External - Usage
ii) Function Procedures
Public, Private - Access control
Internal, External - Usage
---------------------------------------------------
8) Coding conventions
Writing comments
Naming conventions etc...
ex:
Dim num, city, Fso 'Without standards
Dim intNum, strCity, objFso -With naming standards
------------------------------------------------------
9) File System Operations
> What is Computer File System?
> Examples for File System Operations
> How halt user performs File System Operations
> How to perform automatic File System Operations
Using File System Object nosotros tin perform automatic File System Operations
Class value for creating File System Object - ("Scripting.FileSystemObject")
Set Variable = CreateObject("Scripting.FileSystemObject")
Set is VBScript statement
CreateObject is Built function
---------------------------------------------
10) Excel Application Operations
Excel Application Object:
It is used to perform operations on Excel Application/Excel files
Class Value for creating Excel Application object - ("Excel.Application")
-----------------------------------------------
11) Word Application operations
Word Application Object
It is used to perform operations on Word Application / Word documents.
Class value for creating Word Application object - ("Word.Application")
-----------------------------------------------------
12) Database operations
a) Database Connection Object
It is used to connect to Databases
Note: Connection string entirely varies from One Database to another.
Class value for creating database connective object - ("Adodb.Connection")
----------
b) Database Recordset Object
It is used to perform operations on Database Records.
Class value for creating Database Recordset object - ("Adodb.Recordset")
----------------------------------------------
13) Dictionary Object
It is used to define key, value pairs.
Class value - ("Scripting.Dictionary")
------------------------------------------------------------
14) Regular Expressions
Regular Expression - It is a formula for matching patterns
Constant matching -
india.doc - india.doc
Pattern matching
i*.
ia.....
ib..........
.
.
india.doc
-------------------------------------------------------
15) Error Handling
Handling expected too unexpected Errors.
Expected Error:
Whenever nosotros exercise invalid input therefore nosotros tin await the Error.
Note: We exercise Invalid Input for Negative Testing
----------------
Unexpected Error:
Scenarios:
i) Availability of the Resource
ii) Resource Response
iii) Insufficient Resource.
------------------------------
VBScript features for Error Handling:
a) Conditional statements
b) Using roughly built inwards Functions
c) Using Exit Statement
d) Using Option explicit disceptation
e) Using On fault Resume Next
Etc...
-----------------------------------------------