First steps in Salesforce Lightning testing

Updated 4 months ago by Elena Illán

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

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

copadoContext switchToLightning

It is also available "switchToClassic" command to ensure that our test is running on Classic.

  • Access to Applications:

There is more than one way of access to the Copado Applications in order to be recorded. It will depend on the workflow which wants to be tested.

The starting point will be the Salesforce Home Tab. From there, the access to Org Credentials components could be the following from the AppLauncher:

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 config. Sometimes, a tab is not visible and it is located in "More" menu.   

  • Record a new component:

The better way to start making a recording of a NEW component is: 

- Access the component (through AppLauncher or clicking on the tab directly).

- Place on default view and locate "New" button.

- Start the recording making the "New" button assertion and keep on going with the next steps.

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, we have Recently Viewed list by default which continuously changes. Even though we have "All" option selected and any other customized table, it does not guarantee that the record is going to be found. Using the search field is the better way for doing this:

- Move to the component (through AppLauncher or click on the Tab directly).

- Start the recording searching a specific record and continue with the following steps: 

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?