We at Product Support team hopes you had wonderful holiday season and a happy new year with your families and loved ones!
We are kicking things off in 2024 with a Salesforce-focus article! Read more below!
Manually creating locators is sometimes needed within Salesforce due to the way Salesforce handles HTML within their website. Katalon Studio can locate these objects with great frequency, but there a few instances where manual location may be needed:
Starting a new session (be it logging in with a new user, refreshing the page, or running a test case a second time).
Loading the same page as a different user.
Elements changing values (for example, a title might change from ‘button__1123’ to ‘button__2231’ on a fresh page reload).
Therefore, creating a locator manually can reduce errors that occur from the changes in these values.
Additionally, Salesforce can have multiple tabs open but are all located within the same HTML script, so specifying certain locators can reduce element confusion between multiple tabs.
The primary identifiers for HTML are called “tags” or “elements”, these tags identify what the corresponding visual element appears like on an HTML page. Below we will find further information on these tags and elements, and how to use them to locate the elements on the page for use in Katalon Studio.
Some of the common HTML tag examples are
<ui> , and
<li> . These handle different functions within the HTML page, for example,
<div> handles divisions or sections within the HTML page, structuring the page into multiple sections whereas
<a> handles hyperlinks and would typically appear as a hyperlink on the HTML page.
HTML Attributes are details about each HTML tag/element, things like name or title contain the text of the element whereas style alerts an accompanying CSS document about which styling to use for the element.
Combining HTML Tags & Attributes allows us to locate specific elements within an HTML page. For example, for the HTML line:
<span title="Attachments" class="slds-truncate slds-m-right--xx-small" data-aura-rendered-by="20545:0">Attachments</span>
When creating a locator for this element, we would not want to use the Attribute ‘data-aura-rednered–by’ as we can see it has a unique number that is likely to change on a page refresh. Therefore, this element can best be located using this combination of Tag and Attribute information to locate it:
The above XPath/HTML locator will find any element on the HTML page that is of tag type span and contains the title with text “Attachments”.
HTML has several different container, frame, and dividers that split the HTML page into different sections. Typically, we would see these as
<div> for different sections of the page,
<table> for a cell, column, and row style table,
<iframe> as an alternate section type from
Within each of these container or frame types is contained further HTML code, such as an element we may be trying to identify. In the next section, we’ll cover how to locate an element that is nested within one of these containers.
Sometimes when trying to locate an HTML element, it is helpful to include the section that the element is located in to ensure it is found correctly, for example if the element is located in a table we can include the table within the locator information as an outer HTML element, in this example “” is added to identify the first element of type ‘a’:
As we can see in the created locator and screenshot above, Salesforce HTML uses unique attribute names like ‘data-aura-class’ and ‘data-refid’. These can be used just like the other attributes such as ‘class’ or 'title’ for locating elements.
Once we’ve gotten comfortable with the concept of creating the locators, its time to test them out on a real HTML page. Specific to Google Chrome, we can test out our built locator using Command + F or Control + F on the HTML script page in the inspector. We’ll see this will pull up a search bar that we can paste our locator information into, once pasted, if our locator is correct, it will identify the element on the page for us.
If this worked successfully, it is time to move on to Katalon Studio and implementing the element within our test case, if it didn’t work, we may need to spend some time tweaking the locator information.
Once we have named our Test Object and it opens, we should see several different options for locators.
Select the XPATH option and place our locator within the text field and save. Our Test Object is now ready for use within a Test Case.
For the fastest way to handle Salesforce automated testing, it is recommended to first record our desired test steps using Katalon Studio’s Web Recorder. From here, we can follow the exact path through the website we would like to follow and the Web Recorder will save each step we take through the website as a new Test Case.
After creating a new Test Case using this method, if we encounter Test Objects that seem to fail at random or are not being found, we can then take the manual route of locating the element using the steps we covered in the beginning of the article. This should ensure that the elements we want are being located in a specific manner that reduces the chance of the element not being found, while freeing time from having to manually locate each individual element in our Test Cases.
HTML Locator Advanced Selection Methods: Selection methods for Web objects in Katalon Studio | Katalon Docs
If you find this article helpful, then don’t forget to leave us a big heart!