Endtest

Endtest

›Advanced

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • BrowserStack
  • Sauce Labs

Utilities API

Introduction

We provide an API endpoint called Utilities where you can send API requests during your tests in order to process data.

It's easier to use the standard Utilities, which is an option available in the Miscellaneous action, instead of the Utilities API.

Steps

  1. Add a Send API Request step in your test.
  2. Select the GET option from the list of request types.
  3. Add the following URL in the Enter request URL input: https://app.endtest.io/utilities
  4. In the Params section, add the action that you need together with the rest of Quary Params.
  5. The action and the rest of the Query Params need to be added in the standard key-value format.
  6. You can also add Endtest variables in the Params section, simply typing $ in one of the inputs will show you a dropdown with all the available Endtest variables.
  7. You can choose to save the response of that API request into a new Endtest variable.
  8. Go to the Response section, in the Body subsection.
  9. Choose the Store in variable option from the Action dropdown from the the Body subsection.
  10. Add the name of the variable that will contain the body of the response.

Actions

You can choose from different actions:

1. Extract Text After Pattern

The extractTextAfterPattern action can be used to extract a substring from a string, by providing another substring as a pattern.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractTextAfterPattern
textthe full text or the name of the variable
patternthe pattern of text or the name of the variable

For example, let's say you have the following text:

Your validation code is 1234

You can extract the 1234 portion of that text by providing the following pattern:

Your validation code is

That will extract the following substring:

1234

endtest utiliites

2. Extract Text Before Pattern

The extractTextBeforePattern action can be used to extract a substring from a string, by providing another substring as a pattern.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractTextBeforePattern
textthe full text or the name of the variable
patternthe pattern of text or the name of the variable

For example, let's say you have the following text:

1234 is your validation code

You can extract the 1234 portion of that text by providing the following pattern:

is your validation code

That will extract the following substring:

1234

endtest utiliites

3. Extract Numbers From Text

The extractNumbersFromText action can used to extract all the numbers from a string.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractNumbersFromText
textthe full text or the name of the variable

For example, let's say you have the following text:

Your validation code is 1234. Do not share it with anyone else.

You can extract the 1234 portion of that text because it's entirely made up of numbers.

4. Extract Value From JSON

The extractValueFromJSON action can used to get a value from a JSON object.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractValueFromJSON
jsonthe JSON object
namethe name for which you will get the value

For example, if you have the following JSON object:

{"firstName":"John", "lastName":"Doe"}

This is how the Send API Request modal would look like if you want to extract the firstName value:

endtest utilities extract json

Don't forget, you can also use Endtest variables in the Send API Request modal.

5. Extract Item From Array

The extractItemFromArray action can used to get an item from an array.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractItemFromArray
arraythe array from which you will extract the items
indexthe location of the item from the array (the first array index is 0)

For example, if you have the following array:

["apple", "orange", "tomato"]

This is how the Send API Request modal would look like if you want to extract the second item:

endtest utilities extract item array

Since you can use Endtest variables in the Params, Authorization and Headers sections and you can also store the responses in Endtest variables, you can chain together multiple Send API Request steps which can use the extractItemFromArray and extractValueFromJSON actions to extract values from complex JSON objects.

In each Send API Requeststep, go to the Body section from the Response tab and select the option to store the value inside an Endtest variable, which will be used in the next step.

For example, you might have a complex JSON object like this:

{
"employees":[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]
}

If you want to extract the second firstName value from that JSON object, you have to chain together 3 Send API Request steps:

Start by using the extractValueFromJSON action to get the value for the employees item:

[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]

That value will be an array and you can use the extractItemFromArray to get the second item from that array.

{"firstName":"Anna", "lastName":"Smith"}

That item will be a JSON object and you can once again use the extractValueFromJSON action to get the value for the firstName.

6. Extract Last Item From Array

The extractLastItemFromArray action can used to get the last item from an array.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractLastItemFromArray
arraythe array from which you will extract the item

For example, if you have the following array:

["apple", "orange", "tomato"]

This is how the Send API Request modal would look like if you want to extract the last item:

endtest utilities extract last item array

7. Get Text Length

The getTextLength action can used to get the character count of a text.

Query Params that you need to add in the Send API Request modal:

KeyValue
actiongetTextLength
textthe full text or the name of the variable

8. Store Item in Vault

In some scenarios, you might need to manage values across different test suites.

These use cases can usually be handled by using Variables and Import Test Case actions.

But there are other scenarios where one test suite might update a value which is used by other test suites.

You can use the Endtest Vault to store and fetch global values, which can be accessed from all your test suites.

These global values are called items.

The storeItemInVault action can be used to store an item.

The items stored in the Endtest Vault can only be accessed by you and your Team.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionstoreItemInVault
itemNamethe name of the item
itemValuethe value of the item
appIdthe appId for your account
appCodethe appCode for your account

This is how the Send API Request modal would look like:

endtest store item vault

You can also use Variables:

endtest store item vault

After clicking on the Send button, you will see the 'done' message in the Body subsection of the Response section if the request was successful:

endtest store item vault

9. Get Item from Vault

The getItemFromVault action can be used to fetch global values stored in the Endtest Vault.

These global values are called items.

The items stored in the Endtest Vault can only be accessed by you and your Team.

Query Params that you need to add in the Send API Request modal:

KeyValue
actiongetItemFromVault
itemNamethe name of the item
appIdthe appId for your account
appCodethe appCode for your account

This is how the Send API Request modal would look like:

endtest get item vault

After clicking on the Send button, you will see the value of the item in the Body subsection of the Response section if the request was successful:

endtest get item vault

That value can be stored in an Endtest variable and used in your test suite:

endtest get item vault

10. Generate Random Name

The generateRandomName action can be used to generate random names.

KeyValue
actiongenerateRandomName
typefirst, last or full
genderfemale or male

This is how the Send API Request modal would look like:

endtest generate random name

After clicking on the Send button, you will see the value of the name in the Body subsection of the Response section if the request was successful:

endtest generate random name response

That value can be stored in an Endtest variable and used in your test suite:

endtest get item vault

11. Extract Character from String

The extractCharacterFromString action can be used to extract a certain character from a string.

KeyValue
actionextractCharacterFromString
stringthe full text or the name of the variable
indexthe location of the character from the string (the first index is 0)

This is how the Send API Request modal would look like:

get character from text

After clicking on the Send button, you will see the character in the Body subsection of the Response section if the request was successful:

endtest response of character

That value can be stored in an Endtest variable and used in your test suite:

endtest extract character

12. Convert Text to LowerCase

The toLowerCase action can be used to convert a text to LowerCase.

KeyValue
actiontoLowerCase
textthe full text or the name of the variable

This is how the Send API Request modal would look like:

convert to lower case

After clicking on the Send button, you will see the converted text in the Body subsection of the Response section if the request was successful:

convert to lower case result

That converted text can be stored in an Endtest variable and used in your test suite:

convert to lower case variable

13. Convert Text to UpperCase

The toUpperCase action can be used to convert a text to UpperCase.

KeyValue
actiontoUpperCase
textthe full text or the name of the variable

This is how the Send API Request modal would look like:

convert to upper case

After clicking on the Send button, you will see the converted text in the Body subsection of the Response section if the request was successful:

convert to upper case result

That converted text can be stored in an Endtest variable and used in your test suite:

convert to upper case variable

14. Send Email

The sendEmail action can be used to send an email from any endtest-mail.io address.

This feature is not available during the free trial.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionsendEmail
fromEmail address of sender
toEmail address of recipient
subjectThe subject of the email
bodyThe body of the email
attachmentThe File Download Link from the Endtest Drive (optional)
appIdthe appId for your account
appCodethe appCode for your account

send email

15. Math Calculations

The math action can be used to perform mathematical operations.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionmath
operationthe arithmetical operation
itemsa list of numbers, separated by ;

endtest math operations

Supported operations: addition, subtraction, multiplication, division.

You can perform math operations with variables by placing the variable name between double curly brackets:

{{$price}};{{$tax}}

16. Remove Newline Characters

The removeNewLines action can be used to remove Newline characters.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionremoveNewLines
textthe text from which the Newline characters will be removed

endtest remove newline

17. Extract Random Item From List

The extractRandomItemFromList action can used to get a random item from a list.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractRandomItemFromList
listthe list from which you will extract the item

For example, if you have the following array:

orange; apple; tomato

This is how the Send API Request modal would look like if you want to extract the last item:

endtest utilities extract random item from list

18. Extract Value From XML

The extractValueFromXML action can used to get a value from an XML object.

Query Params that you need to add in the Send API Request modal:

KeyValue
actionextractValueFromXML
xmlthe XML object
namethe name for which you will get the value

For example, if you have the following XML object:

<Response>
<CountryCode>US</CountryCode>
<CountryName>United States</CountryName>
<RegionCode>CA</RegionCode>
<RegionName>California</RegionName>
<City>Mountain View</City>
<ZipCode>94043</ZipCode>
<Latitude>37.4192</Latitude>
<Longitude>-122.0574</Longitude>
<MetroCode>807</MetroCode>
<AreaCode>650</AreaCode>
</Response>

This is how the Send API Request modal would look like if you want to extract the City value:

endtest utilities extract xml

Don't forget, you can also use Endtest variables in the Send API Request modal.

← UtilitiesTeam →
  • Introduction
  • Steps
  • Actions
    • 1. Extract Text After Pattern
    • 2. Extract Text Before Pattern
    • 3. Extract Numbers From Text
    • 4. Extract Value From JSON
    • 5. Extract Item From Array
    • 6. Extract Last Item From Array
    • 7. Get Text Length
    • 8. Store Item in Vault
    • 9. Get Item from Vault
    • 10. Generate Random Name
    • 11. Extract Character from String
    • 12. Convert Text to LowerCase
    • 13. Convert Text to UpperCase
    • 14. Send Email
    • 15. Math Calculations
    • 16. Remove Newline Characters
    • 17. Extract Random Item From List
    • 18. Extract Value From XML
Copyright © 2023 Endtest