w8
play

W8 November 17, 2004 1:45 PM T EST A UTOMATION USING S CRIPTING L - PDF document

BIO PRESENTATION SUPPLEMENTAL MATERIALS W8 November 17, 2004 1:45 PM T EST A UTOMATION USING S CRIPTING L ANGUAGES Dion Johnson DiJohn Innovative Consulting International Conference On Software Testing Analysis & Review November 15-19,


  1. BIO PRESENTATION SUPPLEMENTAL MATERIALS W8 November 17, 2004 1:45 PM T EST A UTOMATION USING S CRIPTING L ANGUAGES Dion Johnson DiJohn Innovative Consulting International Conference On Software Testing Analysis & Review November 15-19, 2004 Anaheim, CA USA

  2. Dion Johnson Mr. Dion Johnson has 10+ years of experience in providing IT services to both government and private industry in a manner that has demonstrated expertise in multiple areas of the software development lifecycle. With a Bachelor of Science degree in Electrical Engineering, Mr. Johnson has spent much of his professional career as a consultant, tasked with handling all aspects of the delivery of onsite customer services, particularly in the areas of quality assurance (QA), quality control (QC), software process improvements, and requirements analysis. In addition, Mr. Johnson is also a regular conference speaker, having delivered presentations on several different topics at many conferences over the years. Now, as a leader and consultant for DiJohn Innovative Consulting, Inc., he is helping fulfill the company’s motto of “Making Innovation the Standard”.

  3. Test Automation Using Scripting Languages Dion Johnson dionjohnson@dijohn-ic.com

  4. Introduction Overview � Benefits of Test Automation � Reliable and repeatable � Streamlines the test effort � Reduces cost of test effort � Up until now, there has been a huge gap between perceived benefits and attained benefits � Only available to those with costly commercial tools � Squandered through inefficient practices (i.e. tools on the shelf and unused functionality) � Scripting offers an alternative that closes the gap � This presentation uses Internet Explorer and VBScript in 2 examples www.dijohn-ic.com

  5. Introduction Agenda � Introduction � Advantages � When to Use Scripting � Pre-Implementation � Identify Automation Scope � Learn Scripting Basics � Become Acquainted With Object Models � Scripting Implementation � Create Directory Structure & Pertinent Parameters � Obtain Application Object Properties � Create User-defined Functions � Create Test Scripts � Overcoming Implementation Hurdles 3 www.dijohn-ic.com

  6. Introduction Advantages No licensing – scripting languages � are normally made available with operating systems which leads to: Increased Availability – The use of � the scripts is not limited to the number of licenses purchased Lower costs – The lack of licensing � purchase Only requires a text editor for � developing the scripts (i.e. Notepad) Scripting Language is an industry � standard language as opposed to a vendor created derivative 4 www.dijohn-ic.com

  7. Introduction – When to Use Scripting for Test Automation When to Use Scripting � Indicators that scripting may be a better option: � A commercial automated test tool is not an option � Your organization is uninterested in automation, but you wish to supplement individual manual test efforts � Small automation scope (few tests, applications, configurations, simple functionality) � Technical resources are proficient in programming � Automated scripts need to be available to large numbers of people � Cost benefit analysis (commercial vs. scripting) � Consider resource skill level (training costs) � Consider development costs (time and effort) � Cost of tool � Cost of licenses 5 � # of licenses www.dijohn-ic.com

  8. Pre-Implementation Overview � Prior to script development the following needs to take place: � Obtain an understanding of scripting basics � Study the appropriate Object Model 6 www.dijohn-ic.com

  9. Pre-Implementation Learn Scripting Basics – Scripting vs. Compiled Languages � Compiled Languages � Compiled at ‘Design Time’ by compiler � Requires Integrated Development Environment (IDE) for development � Scripting Language � Interpreted (Compiled) at ‘Runtime’ by a scripting engine � Engine is executed by a Script Host (i.e. Windows Script Host –WSH) by saving the appropriate file with the script language extension (i.e. VBScript has the .vbs extension ) � May be developed in plain text editor (i.e. Notepad) 7 www.dijohn-ic.com

  10. Pre-Implementation Learn Scripting Basics – Object Oriented Concepts Class/Object A set of properties, methods and events that form a � single, modular unit Method A repeatable set of actions � There are two types of methods � � Sub procedure – performs a certain action � Function Procedure – performs an action, returns a value Executed when called by the script � Event A repeatable set of actions � Executed based on a specific user action (mouse-click, � etc.) Collection A collection of data or objects of the same type � 8 www.dijohn-ic.com

  11. Pre-Implementation Learn Scripting Basics – Object Oriented Illustration Shape = Rectangle Text = ‘R Button’ R Button Methods Properties Click Shape Shape = Oval Text Text = ‘O Button’ O Button 9 www.dijohn-ic.com

  12. Pre-Implementation Learn Scripting Basics – Control Flow Functions � Control flow functions provide control over the order in which the code is executed � Control flow functions may be broken down into two categories � Branching Constructs (i.e. If..Then.Else) � Looping Constructs (i.e. Do..While, For..Next) 10 www.dijohn-ic.com

  13. Pre-Implementation Learn Scripting Basics – Language Specific Syntax � Each language may have a different way of writing similar statements � Learn key statements/methods relative to test automation (the following example are specific to VBScript) � CreateObject � GetElementByID � GetElementsByName 11 www.dijohn-ic.com

  14. Pre-Implementation Study Object Model – What It Is & How To Use It What It Is A group of related objects that define an application � and work together to complete a set of related tasks Provides the ability to access and manipulate elements � of an application Identifies application objects, along with information � about each object including: � Position in the Hierarchy � Properties � Collections � Methods How To Use Study the Position, Properties, Collections to determine � how to reference an object Study the Methods to determine how to manipulate an � object 12 www.dijohn-ic.com

  15. Pre-Implementation Study Object Model – Browser Object Model � IE browsers use the DHTML (Dynamic HTML) * Object Model * * � The structure of a * statement that clicks an IE button element would * * * be pressed is (The * following is not actual * syntax, but rather just * the structure of the * statement: * * window.document.element. * click Note: ‘*’ Indicates a collection 13 www.dijohn-ic.com

  16. Pre-Implementation Study Object Model – Browser Object Model Illustration Window Element Document 14 www.dijohn-ic.com

  17. Scripting Implementation Overview � The following steps lead to automation success via scripting: � Obtain Application Object Properties � Developed User-defined Functions � Create Tests as Sub-routines 15 www.dijohn-ic.com

  18. Scripting Implementation Obtain Application Object Properties � Before writing test script code, object properties must be gathered � There is no built in mechanism for learning an application page’s object properties � There are two ways in which this information may be obtained: � Manually – In the case of a browser, the information may be obtained by viewing the source � Automatically – Create a user-defined function that loops through the collection of objects on a page and stores the information in a text file or spreadsheet 16 www.dijohn-ic.com

  19. Scripting Implementation Obtain Application Object Properties � Sample Web Page 17 www.dijohn-ic.com

  20. Scripting Implementation Obtain Application Object Properties � Sample source code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <head> </head> <body> <FORM> <P> <LABEL for="Name">Enter User Name: </LABEL> <INPUT type="text" id="UserName"><BR> <LABEL for="Password">Enter Password: </LABEL> <INPUT type="text" id="Password"><BR> <INPUT type="submit" value="Login" id=”LoginButton> </P> </FORM> </body> 18 www.dijohn-ic.com

  21. Scripting Implementation User-Defined Functions � User-defined functions increase script maintainability through modular, reusable code � Common function categories � Business Functions – Executes primary application functionality � Navigation Functions – Navigates throughout the application � Exception Handling Functions – Handles unexpected application occurrences � Miscellaneous Functions – Miscellaneous actions � Many functions will be application specific, but there are some common functions to consider when using scripting languages 19 www.dijohn-ic.com

  22. Scripting Implementation User-Defined Functions – Business Functions � Business functions are largely composed of inputs and presses/clicks � The example illustrates VBScript inputs in the first two statements of the function and a VBScript button press in the third statement of the function 20 www.dijohn-ic.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend