Manage Elements using REST API


Testsigma allows you to create and update elements using REST APIs. This article explains how to manage elements using APIs in Testsigma.


Prerequisites

Before you begin, ensure you have an API Key from Testsigma application.


Element parameters

Before we check the actual requests, let’s go through some Element properties that you will find in the Request and Response

  • name: Name of the Element to be created
  • locatorType: Either one of ‘xpath’, ‘css selector’, ‘linktext’, ‘classname’, ‘tagname’, ‘name’, or ‘ID’
  • definition: The locator definition for the Element
  • createdBy: The User ID of the creator
  • Status: Status of the Element in Element Review Management. Either ‘Ready’, ‘Draft’
  • screenName: ID of the screen name
  • applicationVersionId: ID of Version where the Element is to be created
  • createdType: Creation Mode of the Element. Either ‘Chrome’, ‘Advanced’, or ‘Manual’

API Specification

Get Elements

This endpoint retrieves all the available elements in the Project.

Request Type GET
Endpoint https://app.testsigma.com/api/v1/ui_identifiers
Authorization Bearer <API_Token>

Get an Element

This endpoint retrieves a specific element in the Project by Element ID.

Request Type GET
Endpoint https://app.testsigma.com/api/v1/ui_identifiers/<ELEMENT_ID>
Authorization Bearer <API_Token>

<ELEMENT_ID> is the id of the specific element you want to fetch.

Create Element

This endpoint creates an element in the application.

Request Type POST
Endpoint https://app.testsigma.com/api/v1/ui_identifiers
Authorization Bearer <API_Token>
Request Body
{
"name": "TestUIID",
"locatorType": "xpath",
"definition": "//test/div",
"createdBy": "USED_ID",
"status": "READY",
"screenNameId": "<SCREEN_NAME_ID>",
"applicationVersionId": "<VERSION_ID>",
"createdType": "CHROME"
}

Update Element

This endpoint updates the existing element in the application.

Request Type PUT
Endpoint https://app.testsigma.com/api/v1/ui_identifiers/<Element_ID>
Authorization Bearer <API_Token>
Request Body
{
"name": "TestUIID",
"locatorType": "xpath",
"definition": "//test/div",
"createdBy": "USED_ID",
"status": "READY",
"screenNameId": "<SCREEN_NAME_ID>",
"applicationVersionId": "<VERSION_ID>",
"createdType": "CHROME"
}