Salesforce Lightning Web Component (LWC) locator support
We’ve been working hard to deliver solutions which 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
In some instances, you may attempt to test web components within a web app and find that traditional XPath and CSS locators are not able to locate an element. This is because web components are encapsulated by the Shadow DOM. Within the Shadow DOM, the elements within a web component are private which means that XPath and CSS locators are unable to 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 on the page which aren’t possible with standard XPath and CSS locators.
Both of these 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 value of the element.
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 in comparison to other tools which still use the limited functionality of traditional XPath libraries.
Though, in some situations, you may need to use By Javascript instead. 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 be used to 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 be used to 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 would like to learn more about using the Provar to test Lightning Web Components, please contact us to discuss your testing strategy and requirements at [email protected].
- General information
- Licensing Provar
- Provar trial guide and extensions
- Using Provar
- API testing
- Behavior-driven development
- Creating and importing projects
- Creating test cases
- Custom table mapping
- Functions
- Debugging tests
- Defining a namespace prefix on a connection
- Defining proxy settings
- Environment management
- Exporting test cases into a PDF
- Exporting test projects
- Override auto-retry for Test Step
- Managing test steps
- Namespace org testing
- Provar desktop
- Provar Test Builder
- Refresh and Recompile
- Reload Org Cache
- Reporting
- Running tests
- Searching Provar with find usages
- Secrets management and encryption
- Setup and teardown test cases
- Tags and Service Level Agreements (SLAs)
- Test cycles
- Test plans
- Testing browser options
- Tooltip testing
- Using the Test Palette
- Using custom APIs
- Callable tests
- Data-driven testing
- Page objects
- Block locator strategies
- Introduction to XPaths
- Creating an XPath
- JavaScript locator support
- Label locator strategies
- Maintaining page objects
- Mapping non-Salesforce fields
- Page object operations
- ProvarX™
- Refresh and reselect field locators in Test Builder
- Using Java method annotations for custom objects
- Applications testing
- DevOps
- Introduction to test scheduling
- Apache Ant
- Configuration for Sending Emails via the Provar Command Line Interface
- Continuous integration
- AutoRABIT Salesforce DevOps in Provar Test
- Azure DevOps
- Running a Provar CI Task in Azure DevOps Pipelines
- Configuring the Provar secrets password in Microsoft Azure Pipelines
- Parallel Execution in Microsoft Azure Pipelines Using Multiple build.xml Files
- Parallel Execution in Microsoft Azure Pipelines using Targets
- Parallel execution in Microsoft Azure Pipelines using Test Plans
- Bitbucket Pipelines
- CircleCI
- Copado
- Docker
- Flosum
- Gearset DevOps CI/CD
- GitHub Actions
- Integrating GitHub Actions CI to Run Provar CI Task
- Remote Trigger in GitHub Actions
- Parameterization using Environment Variables in GitHub Actions
- Parallel Execution in GitHub Actions using Multiple build.xml Files
- Parallel Execution in GitHub Actions using Targets
- Parallel Execution in GitHub Actions using Test Plan
- Parallel Execution in GitHub Actions using Job Matrix
- GitLab Continuous Integration
- Travis CI
- Jenkins
- Execution Environment Security Configuration
- Provar Jenkins Plugin
- Parallel Execution
- Running Provar on Linux
- Reporting
- Salesforce DX
- Git
- Team foundation server
- Version control
- Salesforce testing
- Adding a Salesforce connection
- Assert Page Error Messages on Add/Edit Product
- Dynamic Forms
- Internationalization support
- List and table testing
- Salesforce Release Updates
- Salesforce Lightning Testing
- Salesforce Lightning Web Component (LWC) locator support
- Salesforce console testing
- Visualforce Testing
- Performance Best Practices
- Testing best practices
- Troubleshooting
- Browsers
- Configurations and permissions
- Connections
- DevOps
- Error messages
- Administrator has blocked access to client
- JavascriptException: Javascript error
- macOS Big Sur Upgrade
- Resolving failed to create ChromeDriver error
- Resolving Jenkins license missing error
- Resolving metadata timeout errors
- Test execution fails – Firefox not installed
- Update to Opportunity field validation behaviour
- Licensing, installation and firewalls
- Memory
- Test Builder and test cases
- Release notes