Extension Action

Extension Action Overview

Functionize Extensions, or microservice endpoints, open up test executions to almost unlimited possibilities. Extensions open the Functionize platform to be fully programmable by exposing our runtime object model. Users can manipulate runtime input values, uploaded and downloaded files, screenshots, variables & expressions, TDM data and Orchestration information; the sky is the limit. Extensions offer you the ability to manipulate your tests in nearly countless ways.

These reusable Extension components can be written, saved, and used throughout a user's Functionize account. Extensions can be registered for runtime execution on existing test actions as pre-action/post-action execution or called as a separate, stand-alone test action.

Extension-curl Action Overview

cURL (short for "Client URL") is a command line tool that enables data transfer over various network protocols. It communicates with a web or application server by specifying a relevant URL and the data that need to be sent or received.

cURL makes HTTP requests just like a web browser. To request a web page from the command line, type curl followed by the site's URL: The web server's response is displayed directly in your command-line interface.

The basic cURL syntax is as follows:

curl[options/URLs]

 

Read More: Curl Action 

Read More: Curl Command

For further information: Curl Extension action

Create an Extension-curl Action in Architect

  1. Click the + icon from the main screen of Architect and then select Extension under Advanced actions in the side panel


  2. Click on the Create a new Action


  3. Enter cURL command, sample Command already present:
    curl http://worldtimeapi.org/api/timezone/America/Detroit


  4. Click on the Validate button to get the Result


  5. Click on the Add button in the left side panel

Add an Extension-curl Action in an Existing Test Case

Functionize allows you to add a cURL command through the Extension action that you can add to your test case via Quick Add on the Test detail page and Slider page.

Insert Extension-curl Action via the Test Detail page

  1. Go to the Test details page of the test
  2. Hover where you would like to insert the action 

  3. Open the Insert menu + and select Extension


  4. A dialog box titled Insert Extension will appear, and curl will be selected as default
  5. From here, a user can enter their own cURL command, a sample Command is already present:
    curl http://worldtimeapi.org/api/timezone/America/Detroit


  6. Click on the Validate button to get the Expected Response for the cURL command

  7. Click on the Insert button

Insert an Extension-curl Action via Slider View

  1. Go to the Test details page of the test
  2. Open Slider view via the View Results button or the View button next to any action


  3. Click the Quick Add button at the step where you would like to insert the action.


  4. Open the Insert menu and select Extension


  5. A dialog box titled Insert Extension will appear, and curl will be selected as default


  6. From here, a user can enter their own cURL command, a sample Command is already present:
    curl http://worldtimeapi.org/api/timezone/America/Detroit


  7. Click on the Validate button to get the Expected Response for the cURL command


  8. Click on the Insert button


  9. The new Extension-curl Action will be added below the action

Test your Extension-curl Actions

The user can test the added cURL command by running the test case once they have inserted the Extension-curl Action.

  1. Open Test Detail page
    Note: The Extension-curl Action can be deleted from the Test Detail page or Slider view 
  2. Click on the Execute button
  3. Click on Headless run/ Live Debug/ Live Execution


  4. Check the status of the Extension-curl Action after the execution is complete
  5. The Pass/Fail status will show on the action and the response will show under the Extension TAB of the footer of the Slider view

Add Variable in an Extension-curl Action

Functionize allows users to use Variables within Extension-curl Actions. This enables users to create dynamic requests that can be utilized in their tests. Users can employ variables within a cURL Command in Functionize. The syntax for this involves double curly brackets '{{}}', and the Variables can be used anywhere in the cURL Command.

For example, if you have a variable called myVar that contains a string, you can use it in the cURL Command like this:

curl -X POST -d '{"data": "{{myVar}}"}

 

How to use Variables within a cURL Command

We already have a YouTube tutorial video on this, please see it for more information: Extension Action Tutorial

  1. After you have successfully added your Extension-curl Action, click on the button present in the bottom of the Architect


  2. Click on the Add Variable button


  3. Enter a Variable Name and set the Scope to Local


  4. Select Type as Previous Action


  5. Select the extension step


  6. Select extensionResponse in the Step Attribute drop-down


  7. Select JSON.parse in the Operator dropdown


  8. Select the Property, in this example we selected day_of _year


  9. Click on the Save on the left side panel


  10. setVariable Action will be added to the test in Architect


  11. Add a Verify Action that equals the value that exists on the page


  12. Click on the white circle alongside the Verify Action


  13. Input the Variable value {{fze.local.api}} in DOM Validation section in the left side panel, if the value changes, then it dynamically verifies the updated value rather than the value that was recorded at the time of creation


  14. Click on the Save in the left side panel


  15. Verify Action will be added to the test in Architect

Curl Example

cURL makes HTTP requests just like a web browser and the web server's response is displayed directly in your command-line interface.  Here is an example of a cURL command that calls out to a public endpoint for the World Time API:

//This cURL command for the World Time API will respond with the date, time, 
//day of week, day of the year and timezone of any particular region.
{"command":"curl http://worldtimeapi.org/api/timezone/America/Toronto"}

Enter this command and then click on Validate to see the expected response.

Extension-curl extension Action Overview

The Extension-curl extension Action allows users to use the URL syntax to receive and submit data. Its UI is similar to the API Explorer but is for calling cURL Extensions.

The cURL command can be entered directly into the input field. This allows users to avoid dealing with escaping quotes. Users should be able to enter cURL commands directly, similar to Postman or GitHub, and have them work in a Functionize test.

The Extension-curl extension Action has four HTTP request methods to use in the cURL command:

  • GET: GET requests are used to retrieve data from a specified resource
  • POST: POST requests are used to submit or send data to the server to create a new resource or perform some action on the server
  • PUT: PUT requests are used to update or replace an existing resource on the server with a new representation provided in the request
  • DELETE: DELETE requests are used to request the removal or deletion of a resource on the server

Add an Extension-curl extension Action in an Existing Test Case

Functionize allows you to add a cURL command through the Extension-curl extension Action that you can add to your test case via Quick Add on the Test Detail page and Slider View.

  1. Go to the Test Details page of the test
    Note: The Extension-curl extension Action can also be added on the Slider view.
  2. Hover where you would like to insert the action


  3. Open the Insert menu and select Extension


  4. A dialog box titled Insert Extension will appear, and curl will be selected as the default
  5. Select Extension: curl-extension


  6. Select Method from the drop-down


  7. Enter your cURL command in the Data field


  8. Enter the API call endpoint in the URL field


  9. Enter the Header parameters in the Header field


  10. You will see from your input in the above fields, the Command field is populated automatically


  11. Click on the Validate button


  12. In the Expected Response field, you will get what the probable result will be when you run the test case with your code


  13. Click on the Insert button


  14. After Execution the response will show under the Extension TAB of the footer of the Slider view

Extension-curl extension Action Examples

The Functionize Extension-curl extension Action has the capability to make GET/POST/PUT/DELETE requests to many APIs. Here are some examples of how to use the Extension-curl extension Action:

  • GET Request
    In this example, we are getting a list of projects in an account. The URL and access token for the call can be retrieved from the Functionize API Documentation page found under your Username.
    //DATA
    {"accesstoken":"[TOKENID]"}

    //URL
    https://app.functionize.com/api/v4/project

    //HEADER
    {"accept":"application/json"}
  • POST Request
    In this example, we generate an access token. Client ID/Secret and URL can be retrieved from the Functionize API Keys and API Documentation page found under your Username.
    //DATA
    {"apikey":"[CLIENTID]","secret":"[CLIENTSECRET]","response_type":"json"}

    //URL
    https://app.functionize.com/api/v4/generateToken

    //HEADER
    {"accept":"application/json","Content-Type":"application/x-www-form-urlencoded"}

 

  • PUT Request
    In this example, we are sending a request to edit a Project Environment. Environment ID, URL, and Access Token can be retrieved from the API Documentation page found under your Username.
    //DATA
    {"env":"[ID]","url":"[Environment URL]","response_type":"json"}

    //URL
    https://app.functionize.com/api/v4/project/[Project ID]/env

    //HEADER
    {"accept":"application/json","accesstoken":"[tokenID]","Content-Type":"application/x-www-form-urlencoded"}

 

  • DELETE Request
    In this example, we are sending a request to delete a test case. Test Case ID and Access Token can be retrieved from API Documentation page found under your Username.

    //URL
    https://dev.functionize.com/api/v4/test/[TESTID]

    //HEADER
    {"accept":"application/json","accesstoken":"[tokenID]"}

 

Extension-Postman Collection Action Overview

Postman Collections are groups of saved API requests and related information organized for testing that can be used directly in the Functionize Extension-Postman Collection Action. Postman even allows you to import cURL commands. You can download API tests from Postman and upload them into Functionize.

For more information about Postman, visit this link.

Add an Extension-Postman Collection Action in an Existing Test Case

Functionize allows you to add a Postman Collection through the Extension-Postman Collection Action, which you can include in your test case via Quick Add on the Test Detail page and Slider view.

  1. Go to the Test Details page of the test
    Note: The Extension-Postman Collection Action can also be added to the Slider view.
  2. Hover where you would like to insert the action


  3. Open the Insert menu and select Extension


  4. A dialog box titled Insert Extension will appear, and curl will be selected as default
  5. Select Extension: Postman Collection


  6. Select the Collection Type: File or JSON
    • File: Allows you to import your JSON file, in which you have your command already
    • JSON: Allows you to input your command directly into the field
  7. Upload your JSON file by clicking on the Collection File field


  8. Select the Environment Variable Type: File or JSON


  9. Upload your JSON file by clicking on the Environment Variables File field


  10. Select the Processing Type: Asynchronous or Synchronous


  11. Select the Data File Type: File or JSON


  12. Click on the Insert button


  13. After execution, click on the View button of the Extension-Postman Collection Action and click on Extensions TAB at the bottom of the footer section on the Slider view
  14. There you will find the response to your extension
    • If the Processing Type is Synchronous:


    • If the Processing Type is Asynchronous:

Extension-Postman Collection Action Examples

The Functionize Extension-Postman Collection Action has the capability to make GET/POST/PUT/DELETE API requests directly from Postman in either file or JSON formats. Here are some examples of how to use the Extensions-Postman Collections Action, in these examples we are using Postman Collection files and Environment Variable files to generate a token:

  1. The file type can be attached to the Collection Type field, where the user can view the Extension execution results on the Slider view at the Extension TAB of the action, and if the action fails after execution, the Response field on the Extension TAB will be blank
    • Collection file: New Collection.postman_collection.json
      {
      	"info": {
      		"_postman_id": "*******************************************",
      		"name": "New Collection",
      		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
      		"_exporter_id": "********"
      	},
      	"item": [
      		{
      			"name": "New Request",
      			"request": {
      				"method": "POST",
      				"header": [
      					{
      						"key": "Accept",
      						"value": "application/json",
      						"type": "text"
      					}
      				],
      				"body": {
      					"mode": "urlencoded",
      					"urlencoded": [
      						{
      							"key": "apikey",
      							"value": "*********************************",
      							"type": "text"
      						},
      						{
      							"key": "secret",
      							"value": "*********************************",
      							"type": "text"
      						},
      						{
      							"key": "response_type",
      							"value": "json",
      							"type": "text"
      						}
      					]
      				},
      				"url": {
      					"raw": "https://www1.functionize.com/api/v4/generateToken",
      					"protocol": "https",
      					"host": [
      						"www1",
      						"functionize",
      						"com"
      					],
      					"path": [
      						"api",
      						"v4",
      						"generateToken"
      					]
      				}
      			},
      			"response": []
      		}
      	]
      }
  2. A file type can be attached to the Collection Type and Environment Variable Type field,  where the user can view the extension execution result on the Slider view at the Extension TAB of the action and the variable will be passed in Collection File - the Environment Variables File is used with the Collection File for passing Variables to the Collection File
      • Collection File: Generate token.postman_collection.json
        {
        	"info": {
        		"_postman_id": "************************************",
        		"name": "Generate token",
        		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        		"_exporter_id": "********"
        	},
        	"item": [
        		{
        			"name": "{{baseurl}}generateToken",
        			"request": {
        				"method": "POST",
        				"header": [
        					{
        						"key": "Accept",
        						"value": "application/json",
        						"type": "text"
        					}
        				],
        				"body": {
        					"mode": "urlencoded",
        					"urlencoded": [
        						{
        							"key": "apikey",
        							"value": "********************************",
        							"type": "text"
        						},
        						{
        							"key": "secret",
        							"value": "********************************",
        							"type": "text"
        						}
        					]
        				},
        				"url": {
        					"raw": "{{baseurl}}generateToken",
        					"host": [
        						"{{baseurl}}generateToken"
        					]
        				}
        			},
        			"response": []
        		}
        	]
        }
      • Environment Variables File: New Environment.postman_environment.json
        {
        	"id": "************************************",
        	"name": "New Environment",
        	"values": [
        		{
        			"key": "baseurl",
        			"value": "https://www1.functionize.com/api/v4/",
        			"type": "default",
        			"enabled": true
        		}
        	],
        	"_postman_variable_scope": "environment",
        	"_postman_exported_at": "2023-10-12T05:41:32.877Z",
        	"_postman_exported_using": "Postman/10.18.10-231005-0655"
        }