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
  • SSO
  • 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 Endtest account
appCodethe appCode for your Endtest 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 Endtest account
appCodethe appCode for your Endtest 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. Capitalize Text

The capitalizeText action can be used to capitalize a text, converting the first letter of each word to a capital letter (uppercase letter) and the remaining letters to lower case.

KeyValue
actioncapitalizeText
textthe full text or the name of the variable

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

capitalize text

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.

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

15. 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 Endtest account
appCodethe appCode for your Endtest account

send email

16. Send Slack Message

The sendSlackMessage action can be used to send a message to a Slack Channel.

This feature is not available during the free trial.

And it works only if you connected that Slack Channel to Endtest (details about that here).

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

KeyValue
actionsendSlackMessage
channelthe name of the Slack channel
messagethe message you want to send
appIdthe appId for your Endtest account
appCodethe appCode for your Endtest account

send slack message

17. 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 parameters for operation: addition, subtraction, multiplication, division, round, rounddown, roundup.

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

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

18. 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

19. 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

20. 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.

21. Truncate Text

The truncateText action can be used to extract a substring from a string, by providing the number of characters you want to extract.

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

KeyValue
actiontruncateText
textthe full text or the name of the variable
countthe number of characters or the name of the variable

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

Hello world!

You can extract the Hello portion of that text by providing the following count:

5

That will extract the following substring:

Hello

endtest utiliites truncate text

22. Generate File

The generateFile action can be used to generate a file, by providing the content and the name.

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

KeyValue
actiongenerateFile
fileNamethe name of the file (needs to include the extension)
contentthe content that will be placed inside the file

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

Hello

And you want to save it in a file called sample.txt:

That will generate a text file with the name sample.txt that contains the text Hello.

The file will be automatically stored on our side and the Response Body from that request will contain the online link to that file.

endtest utiliites generate file

23. Extract Latest SMS

The extractLatestSMS action can be used to fetch the latest SMS from a Phone Number assigned to your team.

This functionality requires real phone numbers to be assigned to your team.

We provide real phone numbers for our users. You don't have to use any external service.

If there are no real phone numbers assigned to your team, you can request one by contacting our Support Team.

This functionality is not related in any way to the phone number that you have provide for the Two-Factor Authentication (2FA) for your Endtest account.

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

KeyValue
actionextractLatestSMS
numberthe phone number
appIdthe appId for your Endtest account
appCodethe appCode for your Endtest account
markAsReadtrue or false
deletetrue or false

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

endtest extract latest sms utilities

If everything is correct, the response will contain this JSON:

{
    "from_number": "The phone number that sent the SMS message",
    "to_number": "The phone number that received the SMS message",
    "body": "The body of the SMS message",
    "timestamp": "The UTC timestamp, e.g., 2023-08-29 17:27:57"
}

After the request is sent, the SMS message will be automatically marked as Read if the markAsRead parameter is set to true. That means you won't be able to access it with another request or Extract Latest SMS step.

If the delete parameter is set to true, the SMS will also be deleted. You can also read and delete SMS messages manually in the Team section from the Settings page.

An easier approach to extract the latest SMS is by using the Extract Latest SMS method from the Set Variable action, as described in the Read SMS chapter.

24. Remove All Spaces

The removeAllSpaces action can be used to remove all the spaces from a text.

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

KeyValue
actionremoveAllSpaces
textthe text from which the spaces will be removed

endtest remove all spaces

25. Remove Pattern from Text

The removePatternFromText action can be used to remove a substring from a string.

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

KeyValue
actionremovePatternFromText
textthe full text or the name of the variable
patternthe pattern of text that you want to remove

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

57EUR

You can remove the EUR portion from that text by providing the following pattern:

EUR

The result will be the remaining text:

57

endtest utiliites

26. Get Array Length

The getArrayLength action can used to get the number of items from an array.

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

KeyValue
actiongetArrayLength
arraythe array where you want to count the items
← 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. Capitalize Text
    • 15. Send Email
    • 16. Send Slack Message
    • 17. Math Calculations
    • 18. Remove Newline Characters
    • 19. Extract Random Item From List
    • 20. Extract Value From XML
    • 21. Truncate Text
    • 22. Generate File
    • 23. Extract Latest SMS
    • 24. Remove All Spaces
    • 25. Remove Pattern from Text
    • 26. Get Array Length
© Endtest Inc.