Dani Vainstein & Monika Arora Gautam 1 Utils Layer Building Library Functions.

Slides:



Advertisements
Similar presentations
Dani Vainstein & Monika Arora Gautam 1 Create a Test Set Mercury/HP Utilities.
Advertisements

Dani Vainstein & Monika Arora Gautam 1 Debugging Debugging your scripts.
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Dani Vainstein and Monika Arora Gautam 1 FR Project Building and Setting-up the Infrastructure.
Writing General Procedures Often you will encounter programming situations in which multiple procedures perform the same operation This condition can occur.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Example 2.
String Variables Visual Basic for Applications 4.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Using the Visual Basic Editor Visual Basic for Applications 1.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Introduction to a Programming Environment
Scope of Variables and Constants A Variable or Constant may exist and be Visible for an entire project, for only one form, or for only one procedure Therefore,
Promoting Code Reuse Often in programming, multiple procedures will perform the same operation IN OTHER WORDS – the same piece of code will do the same.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Automation Testing- QTP Rajesh Charles Batch No: Date: jan
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
XP New Perspectives on Introducing Microsoft Office XP Tutorial 1 1 Introducing Microsoft Office XP Tutorial 1.
Dani Vainstein & Monika Arora Gautam 1 Requirement Req0001 Implementation of Requirement Req0001.
Object Variables Visual Basic for Applications 3.
Enhancing User Interaction Through Programming
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Dani Vainstein & Monika Arora Gautam 1 Req0009 Implementation of Req0009.
Dani Vainstein & Monika Arora Gautam 1 Requirement - Req0003 Implementation of Requirement Req0003.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 2 1 Integrating Microsoft Office XP Tutorial 2 – Integrating Word, Excel, and Access.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Chapter 9: Writing Procedures Visual Basic.NET Programming: From Problem Analysis to Program Design.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 3 1 Integrating Microsoft Office XP Tutorial 3 – Integrating Word, Excel, Access, and PowerPoint.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
CPS120: Introduction to Computer Science Functions.
CPS120: Introduction to Computer Science Lecture 14 Functions.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Dani Vainstein & Monika Arora Gautam 1 Requirement Req0002 Implementation of Requirement Req0002.
I Power Higher Computing Software Development Development Languages and Environments.
11/25/2015Slide 1 Scripts are short programs that repeat sequences of SPSS commands. SPSS includes a computer language called Sax Basic for the creation.
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
COPYRIGHT 2010: Dr. David Scanlan, CSUS OBJECTIVES: How to write classes How to create an object from a class using the "New" keyword. How to communicate.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
Top-down approach / Stepwise Refinement & Procedures & Functions.
Programming with Microsoft Visual Basic th Edition
Functions  A Function is a self contained block of one or more statements or a sub program which is designed for a particular task is called functions.
1 Class 1 Lecture Topic Concepts, Definitions and Examples.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Programming Fundamentals Enumerations and Functions.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
An Introduction to Programming with C++1 Void Functions Tutorial 5.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Dani Vainstein1 VBScript Session 8. Dani Vainstein2 What we learn last session? VBScript procedures. Sub procedures. Function Procedures. Getting data.
Automation Testing- QTP Rajesh Charles Batch No: Date: jan
Excel Tutorial 8 Developing an Excel Application
VBScript Session 1 Dani Vainstein.
Requirement Req0004 Implementation of Req0004
User Defined Functions
Exploring Microsoft Office Access 2007
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
VBScript Session 1.
Presentation transcript:

Dani Vainstein & Monika Arora Gautam 1 Utils Layer Building Library Functions

Dani Vainstein & Monika Arora Gautam 2 Topics covered Creating a new function library file. Using the function generator. Modifying functions. Using the Step Generator. Saving a function library. Testing the functions.

Dani Vainstein & Monika Arora Gautam 3 What we have done up to now? We have built an automation infrastructure. Defined QTP global options and Record & Run settings. We created the guiLogin module. Mapped all the objects of the “Login” dialog. Followed the standard naming convention for all the objects. We created two reusable actions under guiLogin Module:  guiLogin  CheckDialog

Dani Vainstein & Monika Arora Gautam 4 Before you start… Before starting the presentation, read about the following topics in QTP help.  Function library.  Function Definition Generator.  Expert and Keyword views.  Step Generator.  Functions and Subs. ByVal, ByRef  CreateObject Function.  Set Statement.  Nothing keyword.  FileSystemObject.FileExist method.  FileSystemObject.BuildPath method.

Dani Vainstein & Monika Arora Gautam 5 About Function libraries If you have set of steps that are repeated in several actions or tests, you may want to consider creating and using user-defined functions for re-usability purpose. A user-defined function encapsulates an activity (or a group of steps that require programming) into a keyword (also called an operation). By using user-defined functions in your tests, your tests are shorter, easier to design, read and maintain. For more information please refer to QTP help, topic Understanding Functions and Function Libraries

Dani Vainstein & Monika Arora Gautam 6 Why do we need a function library? According to the requirement Req0001a we need to check if a file exists under a specific directory. We do not need user-interface to check the existence of file at specific location; hence no GUI operations are required for this action. When we do not perform GUI operations, consider to writing a function. Of course there is many criteria's for writing functions, but this is one of them.

Dani Vainstein & Monika Arora Gautam 7 Creating a function Library. Add a new Function library.  Menu : File  New  Function Library  Hotkey: Press Shift + Alt + N  Toolbar as shown below:

Dani Vainstein & Monika Arora Gautam 8 Saving a Function Library LIB RA TESTS RS DOC FR DAT SETTING RES BATCH ENV Automation BL GL FR.vbs Save the function library file with the name “FR.vbs” under FR\LIB Folder You can also save your library function with extension "qfl" or "txt"

Dani Vainstein & Monika Arora Gautam 9 FileExists Function Req0001a checks whether flightxxx.exe (executable) file exists in the installation folder To check this we will create FileExists function. The function will receive 1 argument – the full path of file and will return True or False value.

Dani Vainstein & Monika Arora Gautam 10 Building the function Add Option Explicit statement at the top of FR.vbs before writing the FileExists function. For more information on Option Explicit statement please refer to the QTP help, topic : Option Explicit Statement Create a new function  From menu : Insert  Function Definition Generator  From toolbar as shown below: Function Definition Generator

Dani Vainstein & Monika Arora Gautam 11 Advantages of Option Explicit Most programming languages require that you explicitly declare variables before you use them. VBScript does not. Some programmers think that this is an advantage, but, in fact it's a serious shortcoming. VBScript creates a new variable in memory every time it encounters a new variable name in code. If you misspell a name VBScript cannot know that it's an error. This can cause serious problems and make it difficult to find the error.

Dani Vainstein & Monika Arora Gautam 12 Advantages of Option Explicit It is recommended to place Option Explicit statement in every script and function library. Option Explicit force you to explicitly declare your variables, otherwise you'll get a run- time error. Using Option Explicit you won't make the mistake of misspelling ( even slightly ) variable names deep in the code.

Dani Vainstein & Monika Arora Gautam 13 Function Definition Generator Function Name: FileExist Type: Function Scope: Public fileFullPathName, By value Description Documentation

Dani Vainstein & Monika Arora Gautam 14 FileExist Function The Function “FileExists” that we’ve just created in the previous slide is a user-defined function. “FileExists” is just a name, you can call it “fFileExists” or any “ExecExists”. Don’t get confused on the FileExists method that belongs to the Scripting.FileSystemObject.

Dani Vainstein & Monika Arora Gautam 15 Modifying the function Determine if a file exists. Determine if exists. Public Function FileExists( ByVal fileFullPathName ) Dim fso ' ** Create a file system object Set fso = CreateObject( "Scripting.FileSystemObject" ) ' ** build the application path FileExists = fso.FileExists( fileFullPathName ) Set fso = Nothing End Function

Dani Vainstein & Monika Arora Gautam 16 FileExists Function To check the existence of our file ( executable ) we have to use Function FileExists. In order to use FileExists Method we declared fso as a Scripting.FileSystemObject variable. For more information on FileSystemObject please refer QTP or VBScript documentation. Then we use the Method FileExists on fileFullPathName argument and True or False value will be returned.

Dani Vainstein & Monika Arora Gautam 17 FileExists Function Just before ending the function, release the fso by setting it to Nothing e.g fso = Nothing Although it’s not necessary, but it’s a good practice to release object variables.

Dani Vainstein & Monika Arora Gautam 18 FileExists – Final Look

Dani Vainstein & Monika Arora Gautam 19 Testing Your Function Open a new Test, don’t save it. Associate the function to the newly created test ( Test1 ).  From menu select : File  Settings  Resources tab  Hotkey : and then click to resources tab.  From toolbar as shown below. Test Settings

Dani Vainstein & Monika Arora Gautam 20 Associating Function to Test1

Dani Vainstein & Monika Arora Gautam 21 Associating Function to Test1

Dani Vainstein & Monika Arora Gautam 22 Using the Step Generator Open the Step Generator.  From Menu : Insert  Step Generator.  Hotkey : F7  From menu as shown below Step Generator

Dani Vainstein & Monika Arora Gautam 23 Step Generator 1. Category: Functions 2. Library: Local script functions 3. Operation: FileExists 4. Value: C:\NotExists.txt 5. Return value : bExists

Dani Vainstein & Monika Arora Gautam 24 Testing the function Add The Print command to bExists. Add a new function call to an existing file in your computer ( just copy paste ) Run The Script. You don’t have to save this test, it’s just for testing the function. bExists = FileExists( "C:\NotExists.txt" ) Print bExists bExists = FileExists( "C:\MyFile.txt" ) Print bExists

Dani Vainstein & Monika Arora Gautam 25 Documenting a Function It’s a coding standard that helps you and your colleagues in future to know - what is the purpose of the Function/Code. The has an advantage of “Auto- Documentation” feature of QTP. For example if you call the function in your test you can see the value of the argument under the document column of Keyword View. Let’ consider following: bExists = FileExists(“c:\MyFile.txt”) Then you will see the result, under document column, as illustrated in next slide.

Dani Vainstein & Monika Arora Gautam 26 Auto Documentation ( Keyword view ) Auto Documentation Column Keyword View only Determine if "C:\myFile.txt" exists. Store the result in the variable 'bExists'. If you don’t see the Documentation column. See next slide.

Dani Vainstein & Monika Arora Gautam 27 Displaying Columns in Keyword view Right Click Columns headers Or from keyword view select "View Options" ( Tools  View Options )

Dani Vainstein & Monika Arora Gautam 28 Summary We have created a new function Library. We add a function using the Function Definition Generator. We’ve modified the action body to our needs. Learned about the Auto-Documentation feature. We learned how to test a function using the Step Generator. We learned how to associate a function library to a test.

Dani Vainstein & Monika Arora Gautam 29 What’s Next? Create a new business module. Create an initialization routine. Open an existing test. Analyzing and design requirements. Creating an Environment File. The Environment Object. Insert calls to Existing action. Passing arguments to reusable actions.

Dani Vainstein & Monika Arora Gautam 30 Special Thanks To Bharathi Babu from India, Pune. Paul Grossman from USA, Chicago. Sumit Singhal from India, Bangalore. Sanjeev Mathur from India, Noida. Prakash Kumar from India, Pune. Joydeep Das from India, Hyderabad. Richi Sharma from USA, New Jersey. Janardhan Kalvakuntla from USA, New England. Ayyappa Koppolu from India, Pune.

Dani Vainstein & Monika Arora Gautam 31 Make sure to visit us for: Tutorials Articles Projects And much