Function Library is a reusable component which can be used multiple times across same or different Test Cases. These functions are user-actions which can be repetitive. You can reference input and output parameters corresponding to the function. This OpKey module is flexible, scalable and robust in nature i.e. function(s) made in this module can be further used among different Test Cases in the form of test steps.
For example: For a shopping portal web-application, four function libraries can be created. One Function library can be for logging into the portal, other for searching the product, third for buying a product and the last one for logging out of the portal. These function libraries can be used in different test cases individually.
Working with Function Library
After successfully login into OpKey Web, select the appropriate Project in which you want to create a Function Library File.
You will be navigated to the screen having as shown.
You can mark the “Don’t show me again” checkbox as checked if you do not wish to view this notification again.
Click “End Tour” to proceed with the process of creating a Function Library file.
How to create a Function Library File?
After clicking on “End Tour” , you may "Click to Create New Artifact".Select Function Library.
The “Function Library” text will appear highlighted.
Click on the highlighted icon to create a New Function Library file. A Create Function Library window will get open as shown
The fields marked with * are mandatory. Enter the Name of the Function Library. You can also enter the Description. Click OK.
Go to Project Workspace > Select the root Folder > Click Create New file icon > Select Function Library.
A Function Library file will be created in the root Folder of the project Workspace.
You may rename the Function Library accordingly.
Right click on root folder > select Create New > select ‘Function Library’.
A Function Library file will be created in the root Folder of the project Workspace.
The Function Library window will open up as shown :
There are two way of creating Function Library : By adding test steps and by recording.
Let’s first discuss about creating Function Library by adding test steps in the next article.
Open in New Tab in Function Library:
Open in New Tab feature enables you to view added artifacts (FL, SR method, Mapped Objects, & Mapped DR) in a Function Library.
You can click on the Open in New Tab option of the added Function Library to open it into a new tab.
You can right click on added Service Repository Method and select Open in New Tab option.
You can view mapped object with a Function Library Test step in detail. Right click on mapped object and then click Open in New Tab.
Creating Function Library by adding test steps
9.1.1 Adding Keywords to Test Steps
Function steps corresponding to the action(s) performed over web application, can be easily added to the Function Library file. Click on 'Add Test Step' button and type the keyword corresponding to your action. A list of matching keywords will be displayed as a search result. Click on the add keyword button to add in your test step. The added test steps can be associated with 'Object Input Argument', 'Data Input Argument' or 'Step Output' as per requirement. In a Function Library, one functional step can be referenced with the other i.e. output of one step can serve as an input for another step.
Function Library (FL) buttons perform the same actions as Test Case buttons do.
Data driving the Function Library by using Object Input Arguments -
Test steps in Function Library can be associated with your Object Repository. Make sure that you have Object Repository file corresponding to your Function Library file. Object Repository file helps in quick Function Library file creation.
There are few advanced settings which can be used to customize test execution.
- ContinueOnError: Check this checkbox if you want execution should be continued even if the error occurs within this step.
- WantSnapshot: check this checkbox if you want to get the snapshot of this step at the time of execution.
- IsNegative: If you check this checkbox, it will change the execution result of the step. It will show a passed step as failed and failed step as passed. This is used for negative testing.
Apart from that above mentioned settings, there are other settings also that can be applied to the whole test steps as shown below.
- AllContinueOnError: Check this checkbox if you want execution should be continued even if the error occurs in all the steps of this file.
- AllWantSnapshot: Check this checkbox if you want to get the snapshot of all the steps at the time of execution.
- AllIsNegative: If you check this checkbox, it will change the execution result of all the steps. It will show a passed step as failed and failed step as passed. This is used for negative testing.
Data driving the Function Library by using Data Input Arguments -
Function Library file allows you to provide input value for a step from Data Input Arguments. You need to provide input data through input from dockable panel.
Select FL Test Step > Go to dockable panel > Click on Input tab > Click on ‘Add’ button to add input parameters.
You can even perform other actions like ‘Delete’, ‘Move Up’, or ‘Move Down’ here.
You can use your Function Library file in your Test case. Follow the below given steps:
Open your Test case file > Go to 'Add Keyword' tab > Scroll down and select your Function library file > click on 'Add Keyword' button.
Using one Function Library within another Function Library -
You can associate a Function Library file with another Function Library file. In a practical scenario, suppose you have a method and you want to call that method into another method. In order to handle such scenarios, FL in FL feature has been developed. In a Function Library file, one functional step can be used within another Function Library file as well.
Select your FL test step > Go to Add Keyword > Scroll down and select your FL to be used.
But, you cannot call the same Function Library file within itself. While doing so, you get an error message that “Recursions are not allowed in OpKey”.
OpKey also allows you to use output of a FL step as input to another FL step.
- Select a test step from Function Library
- Go to the Step Output of right pane and provide a name to the output of selected step
- Go to the Output Parameter of Dockable panel and map it
- Now, this Output Parameter will be visible when we call it into other Test Case or Function Library
- Provide a new name to that output parameter within the TC/FL in which it is used
- Go to the step output and give a name. This name will be visible in output of Data Input arguments
You can perform different actions over the Function Library file by right clicking over the selected test step. These actions are Copy, Paste, Add Step, Delete, Move Up, Move Down, Set to Run, Skip From Run and Record.
Dockable Panel -
There are six tabs in dockable panel in Function Library module namely Details, Input, Output, UsedBy, AuditTrails, Tags & Execution Status. They provide details about the corresponding Function Library.
Details tab under dockable panel gives you details about the Test Case file as to when it was created with the name of the creator, name of the person who last modified it and when this module was last modified.
Input Parameter allows you to provide input values which can be used in FL steps for iteration.
Output Parameter helps you to save step output which is to be used further.
UsedBy tab under the dockable panel provides details about all the other artifacts which use it. Given details include Name, Full Path, Description, Version_No, Component Type.
Audit Trails provides the entire audit history details of the function library. The given details include Task, Field, OldValue, NewValue Time Stamp, and ByUser.
Tags are key-value combination added in the tags panel; they are used for storing information regarding the function library. For example, on which browser or environment we are creating the function library. You can also perform other operations like add, delete, copy, paste, move up and move down.
Execution Status tab in the dockable panel provides you the information about the test execution of the artifact. The information displayed in a tabular form with Session Name, Executed From, Executed By, Execution Time, Executed On & Status as column names.
Creating Function Library by Recording
Recorder (Record & Spy) feature of Function Library is same as Recorder feature of Test Case as already described in earlier topic. For more details, refer: http://opkey.com/Help/docs/opkey-help/working-with-test-cases/creating-test-case-by-recording/
Your Function Library file has been created through recording process as shown below: