Custom Keywords are like OpKey keywords which are created by OpKey users to fulfill their requirement and do specific task during test automation. Once they are created, OpKey users can use them across their test cases and function libraries.
Need of Custom Keywords?
While performing test automation of an application, there may be few scenarios when you need to perform any specific task but unable to do. In such cases, you can create your own Custom Keywords.
Creating Custom Keywords in OpKey:
With the help of OpKey, you can easily handle the situation of Custom Keywords requirement. There are two methods which can be opted:
- Creating Coded Function Library files by writing action specific Java codes and using that Coded Function Library file across Test Cases and Function Libraries, as required.
- Creating Custom Keyword by using Jar files and using Custom Keyword across Test Cases and Function Libraries, as required.
Method 1 –
Creating Coded Function Libraries and using them as an alternative of Custom Keywords
Now, OpKey users need not to write their Java code on an external code editor platform (like eclipse) because there is an advanced feature implemented with OpKey named as Coded Function Library. In fact, Coded Function Library is a better alternative solution of making Custom Keywords. Coded Function Library allows you to write your Java code in its code editor, compile & debug Java code. Once, your written Java Code has compiled successfully, save your Coded Function Library File and call it in your Function Library or Test Case, where it’s required. Execute your Function Library or Test case and analyze execution result. Thus, you don’t need to create a Jar file of your written Java code, upload it to OpKey cloud and make Custom Keyword by using it.
For details about Coded Function Library, please refer:
- Working with Coded Function Library
- Getting started with Coded Function Library
- Prerequisites of Coded Function Library
Method 2 –
Creating Custom Keywords and using them across Test Cases and Function Libraries
This method allows you to create your Custom Keywords and use them across the Test Cases and Function Libraries, as required.
Steps to be followed for creating Custom Keywords:
- Click on Tools menu and select Keyword Management in OpKey Web.
- Keyword Management window opens. By default, Manage Libraries tab is showing. From here, you can manage your existing libraries and upload new libraries (Jar & vbs files containing your code).
- Let us upload a library file for creating a Custom Keyword. Browse, select and click on Open to upload desired jar file.
(For more details about how to create Jar file, please refer: How to add Custom Keyword in OpKey for Selenium Web driver Plug-in)
For example: We are uploading a library named as Custom_Screenshot.
- Once, your Jar file has been uploaded successfully, you can view it in the list of other libraries.
- Let us use the uploaded Jar file for creating required Custom Keyword.
- Switch to the Custom Keywords tab. Click on Add new keyword button.
- Here, you need to enter few basic details about the Custom Keyword to be created.
- Click on Save.
- Once, your Custom Keyword has been created successfully, you can view it in the list of existing Custom Keywords as shown below.
- Now, you can use your Custom Keyword across your Test script.