First Steps in Salesforce Lightning Testing

Updated 2 weeks ago by Copado Solutions

In this article, you will learn how to begin testing in Salesforce Lightning. To learn how to create a test case, see the article Creating Selenium Test Cases

To ensure that your tests are correctly getting into Lightning, it is a good practice to add the next command and param to your recordings:

COMMAND

PARAM 1/TARGET

copadoContext

switchToLightning

The "switchToClassic" command is also available to ensure that your test is running on Classic.

Access to Applications

There is more than one way of accessing Copado applications in order for this to be recorded. This will depend on the workflow you want to test.

The starting point will be Salesforce's Home tab. From there, access to org credentials' components from the App Launcher could be the next step:

COMMAND

PARAM  1/TARGET

open

/lightning/page/home

assertElementPresent

css=ONE-APP-LAUNCHER-HEADER.slds-icon-waffle_container > BUTTON.slds-button

click

css=ONE-APP-LAUNCHER-HEADER.slds-icon-waffle_container > BUTTON.slds-button

verifyValue

copado=field:Find an app or item

type

copado=field:Find an app or item

assertElementPresent

copado=tab:Org Credentials

click

copado=tab:Org Credentials

This flow does not depend on the User tab's configuration. Sometimes, a tab is not visible and it is located within the More drop-down menu.   

Recording a New Component

The best way to start making a recording of a new component is the following: 

  1. Access the component (through the App Launcher or by clicking on the tab directly).
  2. Place on default view and locate the New button.
  3. Start the recording making the New button assertion and keep on going with the next steps.

COMMAND

PARAM  1/TARGET

PARAM 2/VALUE

click

copado=tab:Org Credentials

assertElementPresent

copado=button:New

click

copado=button:New

type

copado=field:Org Name

RT_{!RUN_ID} OrgCredential

click

copado=button#2:Save

Access to a Record

Data records' list views in every component are ever-changing. For every component, you have a Recently Viewed list by default which is constantly changing. Even though you have the All option selected and any other customized table, this does not guarantee that the record is going to be found. Using the search field is the best way of doing this:

  1. Move to the component (through the App Launcher or by clicking on the tab directly).
  2. Start the recording searching for a specific record and continue with the following steps:

COMMAND

PARAM  1/TARGET

PARAM 2/VALUE

open

/lightning/o/copado__User_Story__c/list?filterName=Recent

verifyValue

css=INPUT[title="Search User Stories and more"]

type

css=INPUT[title="Search Salesforce"]

US

assertElementPresent

copado=link:US-0001040

click

copado=link:US-0001040


How did we do?