1. Home
  2. OpKey Help
  3. 10. Working with Coded Function Library
  4. 10.2 Getting started with Coded Function Library

10.2 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 text 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

Go to Project Workspace > Select the root Folder > Click Create New file icon  > Select Coded FL .

A Coded FL file will be created in the root Folder of the project Workspace.

You may rename the Coded FL accordingly.

Method 3

Right click on root folder > select Create New > select ‘Coded FL .

A Coded FL file will be created in the root Folder of the project Workspace.

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. Second section is for User Defined code section which allows you to write user defined code.
  3. Third section is Private Functions which allows you to create user defined private functions in to 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 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.
  • Window containing Linked and Associated Libraries opens as follows.
  • Select your library file from the list of Linked Libraries and click on 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 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 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 connection between OpKey Server and client machine.

Now, behavior 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.

  • Create an FL or a Test Case. Navigate to the Add Keyword section, click on Coded FL tab and select your Coded FL file(s) to be added.

  • The Selected Coded FL will get added in to the FL as shown below:

  • Once the Coded FL gets added in to the FL. You can add other desired steps in to it.
  • Click Run Now, 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 Dockable Panel Tabs of Coded FL:

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

(1) Details:

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

(2) Input:

Input tab under Dockable panel 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:

Output tab under Dockable 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 dockable panel provides information about uses of the Coded FL within a TC or FL.

(5) AuditTrails:

AuditTrails tab under dockable panel of the dockable 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) Tags:

From Tags tab under dockable panel in the Coded FL, you can add tags. These tags are very helpful in case you want to search your specific Coded FL file from the list of the Coded FL files.

(7) Execution Status:

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.

(8) Compilation Result:

 Compilation Result tab provides the result of your Java code compilation in the console view.

Compiling Java Code:

Once, you have mapped desired associated libraries and written your Java Code, you need to compile it. Code compilation leads easily 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 get changed as per the selected plugin. After selecting plugin, you should refresh the page.
  • Compilation process starts which will take few seconds. Once, it get completed, you can view the code errors in the console view showing under Compilation Result tab in dockable panel.

Executing Coded FL in Run Now 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 Now 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.

Executing Coded FL in Debug mode:

It is an alternative way of execution which allows developers to execute test and debug existing bugs quickly and easily. You can click on Debug Now button and follow steps which are similar to the execution through Run Now. During ongoing execution process, you can pause a step, debug it and do more. OpKey Debugger allows you to execute Test, stepwise and view associated input arguments/objects. For Test Execution in Debug mode, you can pause, resume, skip, shrink window, add breakpoint to a Test Step etc. In paused mode, you can view all associated input arguments & object properties and verify them and resume Test Execution later.
During Test Execution, you can also put a breakpoint for a specific Test Step which has not yet been executed. When the Test Step with the breakpoint is executed, the execution process get paused until it is resumed. Breakpoints cannot be applied on a recovery scenario Test Step. If you want to stop your Test Execution at once, click on Stop button to do so. In paused execution mode, Step Into (F6) button allows you to start the Test Execution and automatically pause the execution of next Test Case or Function Library.

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.

 

Follow the below mentioned steps to execute Coded FL in Debug mode:
  • Map Associated Libraries to your code.
  • Write your action code, as required.
  • Select Target Plugin from the list.
  • Save Coded FL file.
  • Click on Debug Now button.
  • Fill all required fields in the Local Execution Wizard (Debug Mode) and click on Next.
  • Execution Process starts successfully.

Here, you can view Debug mode execution logs along with the Debugger Window. Debugger window reflects detailed information about the currently executing test step and other details.

OR Tree Implementation in Input Parameters:

Now, 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. InputParameter 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 and click on it. 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 1 No