Salesforce Automation API Testing with TestZues Framework – DS

Back to Blog
Feature image of Salesforce testing with TestZues

Salesforce Automation API Testing with TestZues Framework – DS

Salesforce API Testing with TestZues Framework

Before moving to the actual framework let’s familiarize ourselves with the basic concept of the salesforce and its UI API.

What Is Salesforce? 

Salesforce is the cloud based technology which provides their built in and customizable CRM(Customer relationship Management) software to the client. It works on the principle of SaaS (Software as a Service) model but not limited to this and also offers PasS(Platform as a Service) and IaaS(Infrastructure as a Service) model services.

Challenges in Salesforce Web Page Automation

  • Salesforce team regularly or frequently update their system for enhancing user experience or fixing underlying issues so for the automation tester has to maintain or update their testing framework regularly
  • Salesforce heavily relies on shadow DOMs which may be nested for their component isolation and this makes tester job difficult as he need to write custom script every time for locating the elements
  • Some of the element identifiers in the salesforce web page are hidden which make it difficult to locate the unique element.
  • The Salesforce webpage mostly contains the dynamic elements i.e. we cannot run the same test case multiple times due locators get changed every time when the test
  • Automation takes more time to access the elements and fails frequently due to heavy DOM structure of the salesforce

So to tackle the above challenges, we have built in the salesforce UI API which makes our task easier for locating the salesforce elements.

What Is the Salesforce UI API?

Basically, the salesforce UI API is different from the salesforce REST API or SOAP API. Salesforce UI API is the API bound to the layout of a page with the data.

The UI API endpoint is here below but the API is divided in three endpoints to tackle Records, Actions and Favourites.


Features of UI API

  • It gives information about the record along with its layout.
  • It gives us the data and metadata about the actions implemented in the UI in JSON format

Elements of UI API

  • Records
  • Layouts
  • List Views
  • Actions
  • Favourites
  • Lookups
  • Active Themes

How to use the UI API in the Framework?

For this, we need a salesforce account on which a connected app is set up. A connected app is a framework which enables an external application to integrate with salesforce using APIs and standard protocols. Follow the below steps to setup the connected app.

1) Setup Salesforce Account

First setup the salesforce developer account or you can get the credentials of salesforce developer from your Admin. For testing purpose follow the steps below to setup the account

  • Go to the link: and complete the sign up process by filling all the fields and verify yourself once you get verification email for setting up the new password and security question.

2) Setup Salesforce Connected App

Now setup the salesforce connected app for using the salesforce UI API

  • Login into the salesforce account
  • Now click on the ‘Setup’ tab
  • Search the ‘App Manager’ from the Quick Find search box available in the left hand side
  • Click on the App Manager from the searched results
  • On the App Manager page, click on the ‘New Connected App’ button. This will open the page for creating the new connected app.

Image of Setup App Manager


  • Fill the mandatory fields like Connected App Name, API name (any desired name), contact email (account registration email)
  • Now click on the ‘Enable OAuth settings’ checkbox.
  • Enter the Callback URL in the input box which will the same URL which you received in the verification email.
  • Now move all the Available OAuth Scopes to selected OAuth Scopes
  • Now click on the save button and then continue button which will create the new connected app
  • Click on the Manage Consumer Details button
  • Enter the verification code which will you receive in the email
  • Now copy and save the both keys – consumer Key and Consumer Secret in the text file which will we use in the test framework

Now let’s discover its implementation in the framework called TestZues.

TestZues Framework

This framework is an open source page object model based on selenium, java, maven and testng. It uses the REST API integrations for parsing the Salesforce UI API for the auto locator feature which locate the salesforce web elements automatically and contextual actions like click, enter text, etc on the salesforce web elements.

Let’s assume that we want to automate the below salesforce page and if we go with the traditional way then we have to go with shadow dom nodes, iframes etc. to locate the element which makes our tests flaky but if we use the salesforce UI API we can directly automate this page at the API level without any headache because we can get every thing of the UI like label, its type, mandatory or not etc in the response API.

image of UI API Automation with TestZues

Here below high-level view of the framework design:

Now each test class extends the BaseTest and uses the PageObject class which extends the SFPageBase and it further extends the PageBase class.

  • BaseTest class instantiates the PageFactory at the runtime via Reflection and sets up the data and post execution cleanup of the webdriver. It also triggers the wrapper methods for abstracting the webdriver internals which are written in the PageBase class and methods to interact with UI API and create locators/interactions are set up in the SFPageBase class.
  • To run the tests : We can use the TESTNG tests file OR by performing a maven build with mvn clean install test goals on the pom.xml

Image of Framework Design


How to use the Above Framework?

  • First the take clone of the TestZues framework from the github repository using the github link-
  • Now open the selenium ide and import the TestZues framework
  • Open the JSON file in the resource folder paste the userId, homepage url, consumer key, consumer secret key in the file

Image of SalesforceUserId

  • Add the Page object class for which the flow has to be modelled

Page object image of blog


  • The class variable needs to be added to the BaseTest class for instantiation

Image of RobinGupta SalesFroce

Image of Message Exception

  • Create the actual test class with references to the web elements and corresponding actions from the page object class

Image of actual test class


Share this post

Back to Blog