Documentation

Looking for something in particular?

Salesforce Lightning Web Component (LWC) Locator Support 

We’ve been working hard to deliver solutions that support Lightning Web Component (LWC) testing, and we also have improvements in the pipeline designed to enhance this capability in the future. The following includes information about the unique challenges associated with testing Lightning Web Components and your options for testing Lightning Web Components using Provar.

The limitations of XPath and CSS locators


Sometimes, you may attempt to test web components within a web app and find that traditional XPath and CSS locators cannot locate an element. This is because the Shadow DOM encapsulates web components. Within the Shadow DOM, the elements within a web component are private, which means that XPath and CSS locators cannot access their elements – causing tests to fail. 

Using Provar to Test Lighting Web Components


If you’ve started to build and use Lightning Web Components in your Salesforce Lightning Experience enabled org, Provar can help. We provide the ability to test Lightning Web Components using two methods. You can use our ProvarX locator or the By Javascript option. Both of these automatically interpret the page structure and generate a unique locator path to locate elements that aren’t possible with standard XPath and CSS locators.

Both options simplify testing by providing the capability to locate elements within a Lightning Web Component by generating Shadow DOM-compliant locators. This enables you to set, read, and assert the element’s value. 

In general, we recommend that you use ProvarX™ when testing Lightning Web Components. ProvarX™ provides a robust and seamless testing experience since it is built to natively adapt to Provar. ProvarX™ is our proprietary implementation of XPath that uniquely navigates the complexities of the Shadow DOM compared to other tools, which still use the limited functionality of traditional XPath libraries. 

However, you may need to use Javascript in some situations. For example, if you are integrating Provar with DevOps platforms and tools that use JavaScript, you can still take advantage of those JavaScript locators within Provar. 

Testing Lightning Web Components with ProvarX™


The ProvarX™ locator can also locate a Lightning Web Component on a Salesforce page by constructing a custom page object within Provar and locating the relevant element. Please refer to this support article for detailed information about using ProvarX

Testing Lightning Web Components with the By Javascript locator


The By Javascript locator can also locate the Lightning Web Component on a Salesforce page by constructing a custom page object within Provar and locating the relevant element. Please refer to this support article for detailed information about using By Javascript

Currently, you can use Provar to test the following Lightning Web Components: 


Elements Interaction
Text Input Field Read/assert, Set
Labels Read/assert
Checkbox Check, Uncheck, toggle
Picklist Set, Set by Index
Lightning-buttons Click, Read Assert
Hyperlink Click, Read Assert
Date field Set
Time field Set

 

If you want to learn more about using the Provar to test Lightning Web Components, please contact us to discuss your testing strategy and requirements at support@provartesting.com.

Review Provar on G2
Documentation library

Trying to raise a case with our support team?

We use cookies to better understand how our website is used so we can tailor content for you. For more information about the different cookies we use please take a look at our Privacy Policy.

Scroll to Top