Introduction


Though there is an extensive list of Natural Language Queries/Templates available with Testsigma, there might be situations where you need to create Test Steps tailored to your needs. That is the reason why Testsigma provides an option for creating Custom Functions. Custom Functions allows us to use Java/Selenium program code to make Test Steps that are customized for our needs.


There are primarily two steps in creating a Custom Function inside Testsigma.


1. Create a Custom Function

2. Create Test Step from Custom Function


Navigation


For creating a Custom Function, you can navigate to the Create Custom Function page as follows:


Select Project > Project Settings > Custom Functions


Steps for creating a Custom Function is explained in detail in the section Create the Custom Function given below.





After creating the Custom Function, we can create a Test Step using the Custom Function by navigating to the Create Test Step page as follows:


Select Project > Applications > Select Application > Select Version > Select Test Case


Steps for creating a Test Step using a Custom Function is explained in detail in the section Create Test Step using Custom Function given below.



1. Create the Custom Function


In the Custom Functions page, click on the Create button to create a new Custom Function. The Create Custom Function page looks as shown below:



Enter the details as given below:


Class Name (required): Enter the name of the Class used in the Custom Function code.


Custom Function Class (required):  Enter the Custom Function code in this field.

Check this article to know more about creating Custom Function code - Custom Function code guidelines


Here's a sample input for the Custom Function:




Enter the required details and click on Create button to Compile and Save to start the compiler. 



If there are compilation errors, they will be shown below the Custom Function code input area. Resolve the compilation issues and click on Compile and Save again to check.

If compilation completes successfully without errors, the Custom Function will be saved successfully and you will get a success notification.


The newly added Custom Function will now be visible on the Custom Functions page.


Now you can use this Custom Function in the Create Test Step page and the process is explained in detail in the following section.


2. Create Test Step from Custom Function

We can use previously created Custom Function in the Create Test Step page by selecting the Custom Function radio button while creating a Test Step.


1. First of all, navigate to the Test Case details page and click on the Create Test Step button to start creating a Test Step.


2. Select the Custom Function radio button at the top of Test Step Creation wizard to create a Test Step from Custom Function.



3. The Test Step wizard changes to a Create Custom Function wizard as shown below:


Enter the required details as follows:

  • Step Details: A detailed description of the Test Step.
  • Function: Enter the Function name inside the Custom Class that is to be executed.
  • *Arguments: Enter the arguments for the Function if there are any.
  • Priority: Select the Priority level that you want to set for this Test Step - Major, Minor or Medium.
  • Mandatory: Select the Mandatory checkbox to make the execution of this step compulsory for a test case.
  • Prerequisite: Select a previously created Test Step if successful execution of that step is mandatory before executing this Test Step.


* Some of the options might be visible only when applicable


Here's a sample input for the Custom Function wizard:


After entering all the required details, click on Create button to Create the Test Step using the Custom Function. We would get a success notification for Test Step creation and the Test Step will be listed as shown below: