iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Centralize Salesforce test locators in a versioned repository organized by page and Lightning component, then expose business actions through page or component objects. Keep selector details out of test cases, scope every lookup as narrowly as practical, and use explicit waits for asynchronous rendering. This design limits the number of files that must change when Salesforce seasonal releases alter markup.
Salesforce does not promise backward-compatible Lightning HTML, CSS, or DOM. A selector that works today can therefore fail after a platform update even when the business workflow is unchanged. The most durable strategy combines stable IDs or attributes, component-aware traversal for Shadow DOM, UTAM or an equivalent page-object layer, and a release-by-release maintenance routine.
Why do Salesforce UI locators need special treatment?
Salesforce Lightning pages are assembled from framework components whose rendered markup can change independently of your business process. Salesforce Developers explicitly warns that “DOM Inspection Tests Are Subject to Change,” so tests that depend on incidental HTML structure are maintenance liabilities. A reliable test should describe an action such as creating an account or saving a contact, not the current nesting of div elements used to render a button.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Centralization gives you one controlled place to update a selector. Without it, the same field may be referenced by several tests with slightly different CSS or XPath expressions. A release then produces a cascade of failures and makes it difficult to distinguish a real regression from a locator change. With a repository and object layer, one definition can serve many scenarios while assertions remain focused on business outcomes.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
- Selector durability: stable IDs, predictable attributes, accessible names, and component boundaries survive more markup changes than generated classes or positional paths.
- Isolation: page and component objects hide lookup mechanics from test code.
- Shadow DOM awareness: component hosts and their shadow roots are treated as explicit boundaries rather than searched as one global document.
- Release readiness: a locator changelog and targeted smoke suite make seasonal-release review repeatable.
What should a centralized Salesforce locator architecture look like?
Use three layers: a locator repository, page or component objects, and tests. The repository defines how an element is found; objects combine those definitions into reusable actions; tests call the actions and verify results. This separation lets you replace a selector without rewriting every scenario that uses it.
1. Locator repository
Group definitions by Salesforce page and reusable component. Give each locator a business-oriented name and document the page or component it targets. Keep raw element handles private to the object that owns them.
utam/
pages/
account.json
components/
contact-form.json
locators/
account_page.ts
specs/
account_smoke.spec.ts
The exact folders can differ by language, but the ownership rule should not: an account-page selector belongs with the account page, while a contact-form selector belongs with the contact component. If the same component appears on several pages, define it once and compose it into each page object.
2. Page and component objects
Expose methods that express user or business actions, such as createAccount(), addContact(), or saveContact(). The method can find fields, enter values, click controls, and wait for the resulting state, while callers remain unaware of the underlying selector.
3. Test code
Keep scenario flow and assertions in the test. A test should state the setup, action, and expected business result. It should not contain a long CSS chain, a shadow-root traversal, or a generated class name.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Which locator strategy is most stable in Salesforce Lightning?
Start with a unique, predictable ID when one is available. If no suitable ID exists, use a compact selector built from a stable attribute or component boundary, scope the search to the smallest useful region, and use accessible labels, roles, or names when your framework can query them reliably.
| Strategy | When to use it | Durability guidance |
|---|---|---|
| Unique ID | An HTML ID is exposed and remains unique and predictable | Selenium’s preferred method when IDs are available, unique, and consistently predictable |
| Compact CSS selector | No suitable ID, but a stable attribute or component boundary exists | Keep the selector short and scope it to a page region or component root |
| Accessible label, role, or name | The test framework supports reliable accessible queries | Express the user-facing control rather than implementation classes |
| Class name | Only when the class is stable and intentionally exposed | Generated Lightning classes are poor candidates |
| Name attribute | The field has a stable, unique name | Scope it to its owning form or component |
| Link text | A link has stable visible text | Use exact or partial text only when wording is controlled |
| Tag name | A tag is unique inside a narrowly scoped root | Avoid global searches that can match several components |
| XPath | No stable ID, attribute, or accessible query is available | Flexible but generally harder to debug; avoid deep absolute paths |
Selenium documents class name, CSS selector, ID, name, link text, partial link text, tag name, and XPath as traditional locator strategies. Its guidance says compact selectors reduce traversal work, while XPath is typically more difficult to debug. That does not make XPath forbidden; it makes it a fallback that should be short, scoped, and tied to a meaningful attribute rather than a complete document path.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Prefer meaning over appearance
A selector such as button.slds-button_brand describes visual styling, not the operation. A selector anchored to a stable accessible name, an intentional data attribute, or a component host communicates why the element matters. If your application can expose a predictable test attribute, treat that attribute as part of the testability contract and keep its value stable across cosmetic redesigns.
Scope every search
Search from the page region, ancestor, or component root that owns the control. For example, locate the account form first and then find its “Save” button, rather than searching the entire page for the first button with that label. Narrow scope prevents collisions when Lightning renders repeated cards, dialogs, related lists, or utility panels.
How do Shadow DOM boundaries affect Salesforce Lightning tests?
Lightning Web Components encapsulate markup in Shadow DOM. A traditional global DOM query may find the component host but not the internal input or button. End-to-end automation must locate the host, obtain its shadow root through the supported WebDriver API, and continue the lookup inside that root—or delegate the traversal to a component-aware page object.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Component-aware traversal
- Locate the outer component host with a stable ID, attribute, role, or other scoped selector.
- Use Selenium 4’s shadow-root methods, or the equivalent API in your framework, to enter the host’s shadow root.
- Find the internal control using a selector owned by that component object.
- Perform the action and wait for the component’s asynchronous state change before returning control to the test.
Do not spread shadow-root handles through test files. Encapsulate them in the component object so a change in internal markup updates one definition. When a component contains another component, compose the child object rather than duplicating a second traversal sequence in every caller.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsShould you use UTAM, conventional page objects, or component objects?
Use the approach that matches your coverage and team languages. UTAM formalizes the page-object pattern with JSON definitions and generated JavaScript or Java objects; conventional page objects provide the same separation when you need hand-written objects; component objects are especially useful for nested Lightning Web Components and Shadow DOM.
| Approach | Primary target | Strength | Trade-off |
|---|---|---|---|
| UTAM JSON page objects | End-to-end UI tests across supported languages | JSON is a single source of truth and can generate JavaScript or Java objects; nested objects mirror component composition | Requires maintaining JSON definitions and the UTAM generation workflow |
| Conventional page objects | End-to-end UI tests in the team’s chosen language | Direct control over selectors, waits, and public methods | Consistency depends on team conventions and code review |
| Component objects | Reusable Lightning components and Shadow DOM regions | Encapsulates component internals and can be composed into page objects | Requires a component boundary that can be identified reliably |
| Jest component tests | Unit tests for individual Lightning Web Components | Fast feedback on component behavior without browser-level navigation | Does not replace end-to-end coverage of integrated Salesforce flows |
| Selenium WebDriver tests | End-to-end browser behavior | Exercises navigation, rendering, and integration across the UI | More sensitive to asynchronous rendering and locator changes |
UTAM documentation describes the JSON page object as “the single source of truth for all your tests, no matter which testing language you use.” That model is useful when several suites or languages must share the same Salesforce interaction definitions. If your project has one language and a small surface area, a carefully reviewed conventional object layer can provide the same architectural benefit without code generation.
Keep Jest close to component source for unit behavior, and reserve browser tests for integration behavior. Salesforce recommends Jest for unit testing individual Lightning Web Components and Selenium WebDriver for end-to-end UI testing. The two levels answer different questions and should not be forced into one locator strategy.
How do you create a locator repository step by step?
Build the repository from the workflows that matter most, not from every element visible in a page inspection. Start with critical account, contact, and opportunity flows, then add definitions as a scenario needs them.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
- Inventory duplication. Search existing tests for repeated CSS, XPath, IDs, labels, and shadow-root traversal. Record where each selector is used and which Salesforce page or component it targets.
- Group by ownership. Move account-page definitions into an account page object, contact-form definitions into a contact component object, and shared navigation into a reusable navigation object.
- Replace brittle expressions. Prefer unique IDs, stable attributes, accessible queries, and scoped CSS. Remove generated classes, positional indexes, and deep absolute XPath wherever a stronger alternative exists.
- Name for the action. Use names such as
accountNameInput,saveButton, orcontactForm. Add a short comment or metadata entry identifying the Salesforce page/component and the reason the selector is stable. - Expose compose methods. Implement methods such as
createAccount(data)orsaveContact(). Keep raw elements private and return a page or component object when navigation changes the context. - Add explicit waits. Wait for navigation, rendering, enabled state, visibility, or the expected post-action condition instead of relying on arbitrary sleeps.
- Migrate callers. Replace inline selectors in tests with object methods. Keep assertions in the test so failures still describe the business expectation.
- Run focused smoke coverage. Exercise login and the critical account, contact, and opportunity paths before expanding the migration.
Example object boundary
class ContactForm {
private readonly firstName = this.root.locator('[data-test="contact-first-name"]');
private readonly lastName = this.root.locator('[data-test="contact-last-name"]');
private readonly save = this.root.getByRole('button', { name: 'Save' });
async fill(data) {
await this.firstName.fill(data.firstName);
await this.lastName.fill(data.lastName);
}
async saveContact() {
await this.save.click();
await this.root.waitForState('saved');
}
}
The example illustrates the boundary rather than prescribing one framework API: selectors and waits stay inside the component, while a test can call fill() and saveContact(). In a UTAM implementation, the same responsibilities are represented by JSON page-object definitions and generated language bindings.
How should public methods and waits be designed?
Public methods should express a complete business action or a meaningful component operation. Avoid exposing a method for every low-level click unless callers genuinely need that control. A method such as createAccount() can fill required fields, submit the form, and wait until the account page or confirmation state is available.
- Keep actions cohesive: a method should leave the object in a documented state.
- Return context deliberately: return the resulting page or child component when navigation or rendering changes the active object.
- Make waits observable: wait for a condition tied to the operation, such as a visible confirmation, a loaded region, or an enabled control.
- Do not hide assertions: the object can verify that an action completed enough to continue, but business assertions belong in the test.
- Fail with context: include the page/component name and business action in error messages so a selector failure is diagnosable.
Explicit waits are particularly important in Lightning because navigation and component rendering are asynchronous. A fixed delay may be too short on one run and unnecessarily slow on another; a state-based wait adapts to the actual browser condition.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How do you make locators resilient to Salesforce releases?
Use a release-aware maintenance loop rather than waiting for a large suite failure. Salesforce seasonal releases can change markup without changing the workflow, so review locator health whenever your supported orgs move to a new release.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Record the baseline. Keep the locator repository and its changelog under version control. Note the Salesforce page/component, selector, owning object, and the release or change that prompted an update.
- Run critical smoke tests. Check login and the account, contact, and opportunity paths first. These tests provide a fast signal that shared navigation, forms, and component boundaries still work.
- Classify failures. Decide whether a failure is a changed selector, a timing problem, a Shadow DOM traversal problem, an environment/configuration difference, or a genuine product regression.
- Update one definition. Change the locator in its repository or page/component object, not in each test that happened to fail.
- Review supported environments. Run the suite on supported browsers and representative Salesforce org configurations. A locator that works in one org configuration may collide or be absent in another.
- Promote the change. Review the selector and its scope, run affected unit and browser tests, and document the reason in the changelog.
Do not treat a passing test as proof that a selector is future-proof. The practical goal is controlled repair: when the DOM changes, the failure points to one owner and the correction propagates to every scenario that uses it.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
How do you diagnose a broken Salesforce locator?
Start by identifying the first failed lookup and the object that owns it. Then use the symptom to choose the next check.
The element is not found
- Confirm that the test is on the expected page and that navigation has completed.
- Check whether the element is inside a component shadow root; if so, locate the host and traverse the root before searching.
- Inspect whether the selector relies on a generated class, positional index, or stale absolute XPath.
- Verify that the test is using the correct page or component object for the current org configuration.
The wrong element is found
- Narrow the search to the owning form, card, dialog, page region, or component root.
- Replace a broad tag, class, or text query with a unique ID, stable attribute, or accessible name.
- Check for repeated Lightning components rendered on the same page.
The element exists but the action fails
- Wait for the control to become visible and enabled.
- Wait for asynchronous rendering or navigation after the preceding action.
- Confirm that the object has entered the correct shadow root and that the element handle is not stale after a rerender.
The failure appears only in one org or browser
- Compare page configuration and component composition across representative orgs.
- Run the same smoke path on each supported browser.
- Prefer a locator based on stable semantics rather than a browser-specific DOM detail.
How should unit and end-to-end coverage be divided?
Use the cheapest test level that can prove the behavior. Jest tests should cover the logic and rendering behavior of an individual Lightning Web Component. Selenium WebDriver or another browser harness should cover integrated navigation, server-backed flows, component composition, and the final user-visible outcome.
- Component unit test: verify that a component responds correctly to inputs and events without depending on Salesforce page navigation.
- Component object test: verify that the object can locate and operate its encapsulated controls in a browser context.
- Page-flow test: verify that account, contact, or opportunity actions work across composed components and navigation.
- Smoke test: run a small, stable set after a release or deployment to detect locator and environment failures quickly.
Duplicating every unit assertion in browser tests increases maintenance without improving confidence. Conversely, omitting browser coverage leaves Shadow DOM traversal, navigation, and asynchronous integration untested.
Recommended Free Tools
What is a practical adoption checklist?
- Inventory duplicated selectors and assign each to a page or component owner.
- Choose a single locator repository format, such as UTAM JSON or language-native object definitions.
- Prioritize unique predictable IDs, then compact scoped CSS or accessible queries.
- Remove generated-class, positional, and deep absolute-XPath dependencies where possible.
- Model Lightning Web Components as objects and compose nested objects to match the UI.
- Keep business actions public and selector details private.
- Add explicit waits for rendering, navigation, enabled state, and post-action confirmation.
- Keep assertions in tests and component behavior tests close to component source.
- Run login and critical account, contact, and opportunity smoke flows on supported browsers and representative org configurations.
- Review failures after every Salesforce seasonal release and maintain a locator changelog.
For the underlying platform guidance, see Salesforce Developers’ discussion of DOM inspection tests and recommended Jest usage at https://developer.salesforce.com/docs/platform/lwc/guide/testing-dom-api.html. UTAM’s page-object model is documented at https://developer.salesforce.com/docs/platform/utam/guide/what-is-utam.html. Selenium’s locator recommendations, including its preference for unique predictable IDs, are at https://www.selenium.dev/documentation/test_practices/encouraged/locators/.
Frequently Asked Questions
Can a centralized locator repository support more than one programming language?
Yes. UTAM is designed for this case: its JSON page objects can generate JavaScript or Java objects, allowing multiple suites to share definitions. If you use hand-written objects, keep the same page/component ownership and business-method contract in each language.
Where should a locator changelog record a selector change?
Record the owning Salesforce page or component, the old and new selector, the release or markup change that required the edit, and the smoke tests used to verify it. Keeping that history beside the repository helps future maintainers recognize a known platform change instead of reintroducing the brittle expression.
What should teams do when a Lightning component is rendered more than once?
Locate the repeated component’s container first, using a business-specific ancestor or region, and then resolve the control inside that container. Never rely on the first matching element or a positional index when the page can display several instances.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteIs a passing browser test enough to certify a locator?
No. A passing run proves the locator worked in that browser, org configuration, and page state. Validate the critical smoke path across supported browsers and representative configurations, then review it again after Salesforce seasonal releases.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

