Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide Version 1.0 January 2010

DISCLAIMER Verbatim copying and distribution of this entire article is permitted worldwide, without royalty, in any medium, provided this notice is preserved.

Table of Contents

TABLE OF CONTENTS 1.

INTRODUCTION ................................................. 3 1.1.

2.

3.

Purpose .......................................................... 3

CREATING NEW TEST ............................................. 4 2.1.

Web_Framework Class .............................................. 4

2.2.

User Defined Function Class ...................................... 8

2.3.

Common Function ................................................. 10

2.4.

Setting the Environment ......................................... 11

2.5.

Driver Script ................................................... 13

TEST EXECUTION .............................................. 17

REFERENCES ..................................................... 18

Open2Test.org

Page ii

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

1.

Introduction

1.1.

Purpose This document describes the settings and how to get started with keyword-driven scripting in Oracle’s OpenScript.

Open2Test.org

Page 3

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

2.

Creating New Test

2.1.

Web_Framework Class Open2Test Test Automation Framework for OpenScript has been created as a class, to include the powerful features of OOPS concept. To implement Open2Test Automation Framework in projects, an instance of Web_Framework class must be created in the calling script. Follow the steps below for setting the environment:

Open2Test.org



In OpenScript Tester’s Perspective, choose ‘File  new’ from the menu bar, and then select the option ‘Functional Testing  Web’ in the ‘New Project’ window:



Enter the required name in the ‘New Web Functional Test Script’ window and click on the ‘Finish’ button:

Page 4

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

Open2Test.org



In the generated script, navigate to the ‘Developer Perspective’ option by choosing the menu ‘View  Developer Perspective’.



Navigate to ‘Java Code’ view, by choosing the tab ‘Java Code’ at the bottom.

Page 5

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide •



Click on the ‘Package Explorer’ icon available in the left pane to view the ‘Package Explorer’.

Right click at the folder level and choose ‘New  Class’ from the popup menu.

Open2Test.org

Page 6

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide •

In the ‘New Java Class’ window, enter the package name as ‘com.Open2Test.OpenScript’ and class name as ‘Web_Framework’ and click on the ‘Finish’ button.



Copy the OpenScript Framework source code contents from the ‘Web_Framework Class’ notepad file (downloaded from Open2Test.com) and paste it in the newly created class.

Open2Test.org

Page 7

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

2.2.

User-Defined Function Class

Again right click at the folder level, and choose the option ‘New  Class’. In the ‘New Java Class’ window, enter the package name as ‘com.Open2Test.Oscript’ and class name as ‘UDF’ and click on the ‘Finish’ button.

Open2Test.org

Page 8

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

Copy the User-Defined Function source code contents from the ‘UDF_Class’ notepad file (downloaded from Open2Test.org), paste them in the newly created class, and save the details.

Open2Test.org

Page 9

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

2.3.

Common Function

To create a class for ‘Common Functions’, again right click at the folder level and choose ‘New -> Class’. In the ‘New Java Class’ window, enter the package name as ‘com.Open2Test.Oscript’, enter the class name as ‘CommonFn’, and click on the ‘Finish’ button. Copy the Common Function source code contents from the ‘CommonFn_Class’ notepad file (downloaded from Open2Test.org), paste it in the newly created class, and save the details.

Open2Test.org

Page 10

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

2.4.

Setting the Environment

After creating the three classes under package ‘com.Open2Test.Oscript’, we should share it to be able to refer from other classes by following the steps below:



Open the ‘Package Explorer’ and expand the tree view at the folder level. Expand the ‘META-INF’ folder node and double click on the ‘MANIFEST.MF’ file.

Open2Test.org

Page 11

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide



In the Manifest.MF file, click on the ‘Runtime’ tab available at the bottom.



Click on the ‘Add’ button in the ‘Exported Packages’ section and select the package ‘com.Open2Test.Oscript’ from the ‘Exported Packages’ window.

Open2Test.org

Page 12

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide



Save the changes.

Now we have successfully exported the package containing the framework and related classes, which we will be using in our driver class for Open2Test implementation.

2.5.

Driver Script

To create Driver Script, select ‘File -> New -> Project -> Web’. The system will create a new script containing the nodes ‘Initialize’, ‘Run’ and ‘Finish’. Navigate to Java Code view of the script and paste in the source contents of ‘DriverScript_Class’ notepad file that were downloaded from the ‘Open2Test.org’ website. In the pasted source code, provide the following three values as parameters while creating the instance of ‘Web_Framework’ class: 1. Path of the Keyword Test Case ‘.csv’ file

Open2Test.org

Page 13

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide 2. Path of the Object Library of AUT 3. Alias name of the Databank file ‘.csv’ file (Optional; if no Databank has been defined, enter ‘null) Note: Enter the path of the files as ‘C:\\KTC.CSV’ (Observe ‘\\’ instead of ‘\’ in drive path) Note: To use Databank in Driver Script, the user needs to configure the .csv file with Driver Script by choosing ‘Script  Configure Databank’ from the menu bar. The user needs to pass the alias name of the Databank file as a parameter to Web_Framework object. The user could observe that the system would throw an error message stating Web_Framework Class and ‘com.Open2Test.Oscript’ package could not be found.

Now open the ‘Package Explorer’ and drill down to ‘MANIFEST.MF’ file of ‘METAINF’ folder in the tree view. In ‘MANIFEST.MF’ file, open the ‘Dependencies’ tab by clicking at the bottom of the file.

Open2Test.org

Page 14

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

Open2Test.org

Page 15

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide In the ‘Dependencies’ tab, click on the ‘Add’ button available in the ‘Imported Package’ section and search for the package (com.Open2Test.Oscript) exported in the section 2.4.

Click on the ‘OK’ button and import the package as a dependency in the current script and save the changes. Note: The package exported in section 2.4 will be available only when the script containing the package is open. If the containing script is closed, the package will no longer be available in ‘Package Selection’ window. Now navigate to the created Driver Script. The user can observe that the Class not found and Package not found errors have disappeared. Repeat the same steps for creating the required number of test scripts by varying the Keyword Test Steps and Object Library as appropriate.

Open2Test.org

Page 16

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

3.

Test Execution

Make sure the paths of the Keyword Test Case, Object Library, and Alias name of the Databank file are correct, and then click on the ‘Playback’ button. The system will perform the actions as defined in the Keyword Test Case on the objects provided in the Object Library. The user can find the results of the test execution in the ‘Results’ pane of the OpenScript.

Open2Test.org

Page 17

Open2Test Test Automation Framework for OpenScript (Web) - Quick Start Guide

References •

Oracle OpenScript Help documentation

Open2Test.org

Page 18