1. Home
  2. Opkey Help
  3. 9. Working with Function Libraries
  4. 9.7 Getting started with Coded Function Library

9.7 Getting started with Coded Function Library

After successfully login into OpKey Web, select the appropriate Project in which you want to create a Coded Function Library.

  • You will be navigated to the OpKey Dashboard screen as shown below:

  • 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 Coded Function Library  file.

How to create a Coded Function Library File?

Method 1

After clicking on “End Tour”, you may “Click to Create New ArtifactSelect Coded Function Library from the dialer page.

  • The Coded Function Library description will get highlighted.

  • Click on the highlighted icon to create a New Coded Function Library file. A Create Coded FL window will get open as shown
  • The fields marked with * are mandatory. Enter the Name of the Coded FL . You can also enter the Description. Click OK.

Method 2

Select any existing Function Library and switched its mode to Coded Function Library.

A Coded FL file will be created in the Function Library and this code can directly be called and used in a Test Case or a Function Library.

NOTE: Recursions are not allowed in OpKey.


The Coded Function Library window will get opened. It has three major sections:

  1. First Section is the Import Section which allows you to import any required pre-built library.
  2. The second section is for User-Defined code section which allows you to write user-defined code.
  3. The third section is Private Functions which allows you to create user-defined private functions into it.

You can write the specific java code in the Coded Function Library.


Getting Familiar with the Coded FL Buttons:

Mapping Associated libraries with Coded FL

Libraries are the Jar files which contain specific Java code for performing an action. These libraries are created by user for creating Custom Keywords. Now you can import those libraries to the Coded FL, compile them here, execute them and use them in Custom Keywords, as required. Used associated Libraries can be executed in Run Now and Debug now mode.

Follow below-given steps to associate and use pre-built libraries:

  • Click on the Libraries tab.
  • A window containing Linked and Associated Libraries opens as follows.
  • Select your library file from the list of Linked Libraries and click on the Associate button to add them to the Associated Library list.

Let us see now how to import Package(s) to the Coded FL from the Associated Libraries. You should have to know the Package, Class of the Associated Library/Jar file.

In the below-given screenshot, you can have a look at the Associated Library file code (package and class).

  • Write the Import syntax for importing Package(s) and Class of the associated jar file in the Import Section of the Coded FL as:

import Package_Name.Class_Name

For example: Here, SumPck is the Package name and Division is the Class name in the associated library.

  • Let us write a division code in the User Code section. Here, we will divide 10 by 5 which results output as 2. You need to add an Output Parameter of Integer type which will store the Output of Division.

  • Once, codes are written successfully, Save it.

Intellisense in Coded Function Library

While writing Java Code in the Coded FL editor, Intellisense feature helps the user to view suggested syntax which can be used. Make sure that the Intellisense toggle button is in On state. User can press Ctrl+Spacebar button to trigger the Intellisense and view list of all the suggested syntax to be used.

OpKey Coded FL Compiler window appears. It establishes a connection between OpKey Server and the client machine.

Now, the behaviour of Intellisense has been improved. This new version now supports:

  1. Global Variables
  2. Local variables
  3. Classes name
  4. Input parameters
  5. Output Parameters
  6. The Object, Class, Method, Local variables in Intellisense proposal window are visible with their icons.
  7. Intellisense proposal window now shows all context of available plugins.
  8. The Classes and Methods of the imported package from associated jar, are now visible in the Intellisense proposals.


Using Coded FL file in Test Case & Function Libraries:

  • You can map your Coded FL file with the Test Case or Function Library file by selecting its mode to Coded FL.
  • Create an FL or a Test Case. Navigate to the Add Step icon, select your  Function Library file(s) to be added.
  • Function Library to be successfully added in the corresponding Test Case or Function Library, to use this Function Library in Coded FL state switch its mode to Coded FL as shown below:


  • The Selected Coded FL will get added into the FL.
  • Once the Coded FL gets added into the FL. You can add other desired steps into it.
  • Click Run, to execute the FL.
  • The Execution wizard window will get opened and the FL will get executed.
  • You can also generate the desired reports.

Getting familiar with the Details Tabs of Coded FL:

There are various tabs in the dockable panel of the Coded FL. They are used for performing different tasks.

(1) Information:

Here, you can view detailed information (created by, created on, modified by and modified on) about the Coded FL.

(2) Input Parameter :

Input  Parameter tab under the Details section allows you to add Input Parameters to the Coded FL. Added Input Parameters get reflected in the Non-editable section of Coded FL as shown below.
(3) Output Parameter:

Output tab under Details panel allows you to add Output Parameters to the Coded FL. Added Output Parameters get reflected in the Non-editable section of Coded FL as shown below.


(4) UsedBy:

UsedBy tab under the details panel provides information about uses of the Coded FL within a TC or FL.

(5) AuditTrails:

AuditTrails tab under details panel provides detailed information (Task, Field, Old Value, New Value, Time Stamp and By User) about the entire changes made to the Coded FL by the user.

(6) Backup:

The backup tab provides the details about any backup activity is done for the corresponding Function Library. The given details include Name, No, comment, and Actions.
For details about the Backup, kindly refer: Backup

Compiling Java Code:

Once, you have mapped desired associated libraries and written your Java Code, you need to compile it. Code compilation leads to easy identification of existing code errors. You can view the code errors in the Compilation Result tab showing under the dockable panel. You need to follow below-given steps while compiling Java code in Coded FL:
  • Map Associated Libraries to your code.
  • Write your action code, as required.
  • Save Coded FL file.
  • Click on Compile button.
  • When you select the required plugin from the dropdown list, your code gets changed as per the selected plugin. After selecting a plugin, you should refresh the page.
  • Compilation process starts which will take a few seconds. Once, it gets completed, you can view the code errors in the console view showing under Compilation Result tab in the dockable panel.

Executing Coded FL in Run mode:

Once, your java code has been compiled successfully, you can execute your Coded FL file. However, it’s not mandatory to compile your Java Code before execution through Run Now. When you execute your Coded FL file, code compilation process runs prior to execution.
  • Map Associated Libraries to your code.
  • Write your action code, as required.
  • Select Target Plugin from the list.
  • Save Coded FL file.
  • Click on Run button.
  • Fill all required fields in the Local Execution Wizard and click on Next.
  • Execution Process starts successfully.

Here, you can view the Execution Logs.

  • Once, execution process has completed, you can view at the Execution Result.

noteWhile working on Coded Function Library feature on Mac machine, local OpKey Agent will not be required for executing Coded Function Library. You can now execute your Coded FL through Spock Agent. Furthermore, you don’t need to install different plugins as Local Agent is not required.


noteNow, Spock Agent in Coded Function Library in OpKey supports Java 11. You can execute your Coded FL (developed with Java 11) on Spock Agent.

OR Tree Implementation in Input Parameters:

Now, the user can view the list of OR tree added in the Input Parameter and use them within the Coded Function Library, as required. You can add new Input Parameter as OR Object Data Type and provide default OR value from the OR tree.

  • Click on Input Parameter tab, opens as shown below:

  • Click on Add button to add a new Input Parameter. An Input parameter with input-parameter-1 name has been added.
  • Navigate to Data Type dropdown tab. Select ORObject from the dropdown list of Data Types.

  • Navigate to the Default Value tab and click on it.
  • Browse and select your desired object. Your ORObject input parameter has been added successfully to the Coded Function Library.

Was this article helpful to you? Yes No