testRigor & Salesforce
  • NO-CODE UI TESTING: Guide for testRigor & Salesforce
  • Getting Started
    • Get a Salesforce Hands-On Playground Org (free)
    • Get testRigor (free) and create a Test Suite
    • Create Test Case (T00001)
    • Navigation in Salesforce
    • Navigation in testRigor
  • BASIC TEST CASES
    • Record, edit and play a Test Case (T00002)
    • Create and convert a Lead (T00003)
    • Create more records (T00004)
    • Check Account Validation Rule (T00005)
  • ADVANCED TEST CASES
    • Account Action and List View Button (T00006)
    • Validate Field Value Using REST API (T00007)
    • E2E: Lead entry (Titan) ➔ Salesforce ➔ Email
  • OTHER TEST SCENARIOS
    • Submit a Test Lead
    • TH: Opportunity Won THEN Create Contract
    • Monitor data in your website
    • Monitoring in Production
  • FLOW TEST CASES
    • Screen Flow: Update Email Address
  • E-BIKES SAMPLE APP
    • E-Bikes sample app description
    • testRigor version of the UTAM TEST (EBIKES-00001)
    • Product Explorer - Electra X3 (EBIKES-00002)
    • Reseller Order - Create (EBIKES-00003)
    • Case - Create (EBIKES-00004)
  • LWC RECIPES SAMPLE APP
    • LWC Recipes sample app description
    • Test Case for LWC Recipes (LWC-00001)
  • CORAL CLOUDS SAMPLE APP
    • Coral Clouds sample app description
    • Experience - Generate Description using AI (CC-00001)
    • Experience - Generate Reviews Summary using AI (CC-00002)
  • MORE INFORMATION
    • About testing
    • About testing in Salesforce 🤔
    • About test automation
    • About Test-Driven Development (TDD)
    • About testRigor
    • About using testRigor
    • About other solutions
  • FEEDBACK
    • Questions? - Comments!
Powered by GitBook
On this page
  • Preparations in Salesforce
  • Setup > Allow OAuth Username-Password Flows
  • Setup > Create a Connected App
  • Get the Security Token for the User
  • Preparations in testRigor
  • Create Global Variables for Salesforce REST API
  • Create Reusable Rules in testRigor
  • Create Test Case (T00007)
  • APPENDIX
  • Record these details for setting up Salesforce REST API
  1. ADVANCED TEST CASES

Validate Field Value Using REST API (T00007)

PreviousAccount Action and List View Button (T00006)NextE2E: Lead entry (Titan) ➔ Salesforce ➔ Email

Last updated 4 months ago

  • this is even more "advanced"

  • for experts in Salesforce, REST API etc

Authentication errors are hard to troubleshoot. Therefore

  • Double check everything.

  • Try to authenticate using Postman.

  • I've seen problems potentially related to characters like "+" in the username or password.

  • In some cases it's faster just to spin up a new Hands-On org and try again (I just did this).


Preparations in Salesforce

Setup > Allow OAuth Username-Password Flows

  • click cog > "Setup"

  • enter to Quick Search: "identity"

  • click: "OAuth and OpenID Connect Settings"

  • turn on: "Allow OAuth Username-Password Flows"


Setup > Create a Connected App

  • click cog > "Setup"

  • enter to Quick Search: "app manager"

  • click: "App Manager"

  • click: "New Connected App"

  • select: "Create a Connected App"

  • click: "Continue"

  • enter details for the New Connected App

    • Connected App Name: Connected REST API

    • API Name: Connected_REST_API (gets populated automatically)

    • Contact Email: [your email]

    • Enable setting OAuth Settings: checked

    • Callback URL: https://localhost:8080

    • Selected OAuth Scopes

      • scroll to Full access (full)

      • click: "Add"

    • Disable setting "Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows": unchecked

  • click: "Save"

  • click: "Continue"

  • click: "Manage Consumer Details"

  • enter the verification code that was sent to your by email

  • Copy-paste the record the Consumer Key to your records

  • Copy-paste the record the Consumer Secret to your records

  • wait: 10 minutes


Get the Security Token for the User

In Salesforce:

  • click: Profile pic

  • click "Settings"

  • Enter to Quick Search: "reset"

  • click: "Reset My Security Token"

  • click: "Reset Security Token

In your email inbox

  • search for email with this subject: "Your new Your Developer Edition security token"

  • record the security token


Preparations in testRigor

Create Global Variables for Salesforce REST API

  • Navigate to "Test Data"

  • Click: "+ Add"

  • select Type: Text

  • enter Name: "API_SALESFORCE_DOMAIN"

  • Enter: https:// [ Current My Domain URL ] from Setup> My Domain

  • click: "Add"

  • Click: "+ Add"

  • select Type: Text

  • enter Name: "API_CONSUMER_KEY"

  • paste to "Value": the Consumer Key from your records

  • click: "Add"

  • Click: "+ Add"

  • select Type: Text

  • enter Name: "API_CONSUMER_SECRET"

  • paste to "Value": the Consumer Secret from your records

  • click: "Add"

  • Click: "+ Add"

  • Click: "+ Add"

  • select Type: Text

  • enter Name: "API_SECURITY_TOKEN"

  • paste to "Value": the User's security token from your records

  • click: "Add"

  • Click: "+ Add"

  • select Type: Text

  • enter Name: "URL_Salesforce_record"

  • Enter "[URL]" to "Value"

  • click: "Add"


Create Reusable Rules in testRigor

Create API-0001 - SALESFORCE REST API - Authorize :: API_access_token

  • Navigate to "Reusable Rules"

  • Click: "+ New Rule"

  • Enter Name: "API-0001 - SALESFORCE REST API - Authorize :: API_access_token"

  • Enter Labels: API, Salesforce

  • Enter Steps: [copy-paste the line from the code block below]

  • Click: "Save"


call api post from string with parameters "${API_SALESFORCE_DOMAIN}/services/oauth2/token?grant_type=password&client_id=${API_CONSUMER_KEY}&client_secret=${API_CONSUMER_SECRET}&username=${username}&password=${password}${API_SECURITY_TOKEN}" and get "$.access_token" and save it as "API_access_token"

Create SF-0001 - Grab record ID from record URL :: URL_Salesforce_record :: ID_extracted_from_URL

  • Click: "+ New Rule"

  • Enter Steps: [copy-paste the line from below]

  • Enter Name: "SF-0001 - Grab record ID from record URL :: URL_Salesforce_record :: ID_extracted_from_URL"

  • Enter Labels: API, Salesforce

  • Enter Steps: [copy-paste the line from the code block below]

  • Click: "Save"

execute JavaScript text starting from next line and ending with [END]
  url = testRigor.getStoredValue("URL_Salesforce_record");
  parts = url.split('/');
  recordId = parts[parts.length - 2];

  trCommand = 'save value "' + recordId + '" into "ID_extracted_from_URL"';
  testRigor.execute( trCommand );
  
[END]


Create Test Case (T00007)

  • Navigate to "Test Cases"

  • Click: "+ Add Test Case"

  • Enter Description: "T00007 - Validate field value using Salesforce REST API"

  • Steps:

UTIL-0001 - Set DATETIME_START_LOCAL
login

// CREATE ACCOUNT //
open URL from string with parameters "${URL_SALESFORCE_HOME}/lightning/o/Account/new"
generate from template by string with parameters "!TEST ACCOUNT - ${DATETIME_START_LOCAL} - %%%-%%", then enter into "Account Name" and save as "AccountGenerated"
click "Save"

// validate field value in Salesforce UI
check that page contains stored value "AccountGenerated"

// 
// VALIDATE FIELD VALUE USING REST API
//
grab url and save it as "URL_Salesforce_record"
SF-0001 - Grab record ID from record URL :: URL_Salesforce_record :: ID_extracted_from_URL

API-0001 - SALESFORCE REST API - Authorize :: API_access_token

// QUERY API FOR Account.Name //
save string with parameters "SELECT+Name+FROM+Account+WHERE+Id='${ID_extracted_from_URL}'" as "SOQL"

call api get from string with parameters "${API_SALESFORCE_DOMAIN}/services/data/v62.0/query/?q=${SOQL}" with headers from the string with parameters "Authorization:Bearer ${API_access_token}" and then get "$.records[0].Name" and save it as "result_Name"

check that stored value "result_Name" equals stored value "AccountGenerated"


APPENDIX

Record these details for setting up Salesforce REST API

DETAIL
VALUE
DESCRIPTION

User's security token

_______

  • for authorization

  • to be stored in a global variable in Reusable Rule

Consumer Key

_______

  • for authorization

  • to be stored in a global variable in Reusable Rule

Consumer Secret

_______

  • for authorization

  • to be stored in a global variable in Reusable Rule