ProvarX™
ProvarX™ is an enhanced feature within Automation that is designed to make it easier to test custom and standard web components within a web app where traditional locators like XPath and CSS (used by other test automation frameworks) are unable to find elements within a web component without using a JavaScript locator.
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 the Shadow DOM encapsulates web components. Within the Shadow DOM, the elements within a web component are private, meaning that XPath and CSS locators cannot access their elements.
How the Shadow DOM renders code uniquely
Encapsulating the code from the rest of the web app enables a web component to be rendered, scripted, and styled separately from the main web app. This also allows web components to be reused wherever you like on a web page without fearing code collision. As a result of the Shadow DOM, XPath and CSS locators cannot pierce the Shadow DOM because it is hidden from these locators, and a JavaScript locator is needed to locate elements within the Shadow DOM instead.
How to use ProvarX™ to test web components
This feature simplifies the testing of web components by providing the capability to locate elements within a web component using an XPath query. This is achieved using the Test Builder to create a test step and map an element in a web component using an XPath locator and standard XPath syntax. This enables you to set/read/assert the element’s value, and Provar will automatically access the Shadow DOM.
Testing a standard website using the native Shadow DOM
In the following example, we will locate an element on the https://recipes.lwc.dev/ website, which utilizes the native Shadow DOM. In this scenario, the standard XPath and CSS locators cannot find elements with the shadow tree because these locators cannot cross the shadow boundary.
Step 1: Using Automation, create a Selenium UI testing connection, create a new test case, and test step to use the UI test connection
Step 2: Launch the Test Builder.
Step 3: Once the browser and Test Builder are launched, select the First Name field on the page, right-click the element, and select Add To Test Case.
Step 4: Use the drop-down menu above the Field Locator field to select By ProvarX to identify the ProvarX™ path using standard XPath syntax within the Test Builder. Provar will automatically suggest a default ProvarX™ path.
Step 5: The suggested locator in this instance is as follows. (You will notice that Provar has automatically identified the Shadow DOM elements within the Shadow Tree to generate the relevant locator to traverse the Shadow Tree.)
//recipe-hello-expressions//ui-input[1]//label[normalize-space(.)=’First Name’]/following-sibling::div//input
Testing a Salesforce page with a custom Page Object
The By ProvarX locator can also be used when constructing a custom page object for a Salesforce page to locate an element.
Step 1: Simply select the Page Object for the page structure.
Step 2: Within the Test Builder, use the drop-down menu above the Field Locator field to select By ProvarX to identify the ProvarX™ path using standard XPath syntax. Provar will automatically suggest a default ProvarX™ path.
The suggested locator in this instance is as follows. Provar will automatically generate the ProvarX™ path that uniquely selects the element on the page.
//div[contains(@class, ‘active’) and contains(@class, ‘open’) and (contains(@class, ‘forceModal’) or contains(@class, ‘uiModal’))][last()]//input[@id=’input-218′]
Testing a Salesforce Flexi component
The By ProvarX locator can also locate elements on a Salesforce FlexiPage.
The suggested locator in this instance is as follows. Provar will automatically generate the ProvarX™ path that uniquely selects the element on the page.
//label[normalize-space(.)=’*First Name’]/following-sibling::div//input
Currently, you can use ProvarX™ to test the following:
Elements | Interaction |
Text Input Field | Read/assert, Set |
Labels | Read/assert |
Checkbox | Check, Uncheck, toggle |
Picklist | Set, Set by Index |
Buttons | Click, Read Assert |
Hyperlink | Click, Read Assert |
Limitations
There is a limitation in using the ProvarX™ locator on generic web pages (non-salesforce pages) on the following browsers when interacting with web components using the native Shadow DOM: IE 11.
If you’d like to learn about using ProvarX™ for web component testing, please contact us to discuss your testing strategy and requirements at support@provartesting.com.
For more information, check out this course on University of Provar.
- Provar Automation
- System Requirements
- Browser and Driver Recommendations
- Installing Provar Automation
- Updating Provar Automation
- Licensing Provar
- Granting Org Permissions to Provar Automation
- Optimizing Org and Connection Metadata Processing in Provar
- Using Provar Automation
- API Testing
- Behavior-Driven Development
- Consolidating Multiple Test Execution Reports
- 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
- Japanese Language Support
- Override Auto-Retry for Test Step
- Mapping and Executing the Lightning Article Editor in Provar
- Managing Test Steps
- Namespace Org Testing
- NitroX
- Provar Automation
- Provar Test Builder
- ProvarDX
- Refresh and Recompile
- Reintroduction of CLI License Check
- 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
- Provar Manager
- How to Use Provar Manager
- Provar Manager Setup
- Provar Manager Integrations
- Release Management
- Test Management
- Test Operations
- Provar Manager and Provar Automation
- Setting Up a Connection to Provar Manager
- Object Mapping Between Automation and Manager
- How to Upload Test Plans, Test Plan Folders, Test Plan Instances, and Test Cases
- Provar Manager Filters
- Uploading Callable Test Cases in Provar Manager
- Uploading Test Steps in Provar Manager
- How to Know if a File in Automation is Linked in Test Manager
- Test Execution Reporting
- Metadata Coverage with Manager
- Provar Grid
- DevOps
- Introduction to Provar DevOps
- Introduction to Test Scheduling
- Apache Ant
- Configuration for Sending Emails via the Automation Command Line Interface
- Continuous Integration
- AutoRABIT Salesforce DevOps in Provar Test
- Azure DevOps
- Running a Provar CI Task in Azure DevOps Pipelines
- Configuring the Automation 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
- GitHub Actions
- Integrating GitHub Actions CI to Run Automation 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
- Version Control
- Masking Provar Credentials on CI
- Salesforce Testing
- Best Practices
- Improve Your Metadata Performance
- Java 21 Upgrade
- Salesforce Connection Best Practices
- Testing Best Practices
- Automation Planning
- Supported Testing Phases
- Provar Naming Standards
- Test Case Design
- Create records via API
- Avoid using static values
- Abort Unused Test Sessions/Runs
- Avoid Metadata performance issues
- Increase auto-retry waits for steps using a global variable
- Create different page objects for different pages
- The Best Ways to Change Callable Test Case Locations
- Working with the .testProject file and .secrets file
- Best practices for the .provarCaches folder
- Best practices for .pageObject files
- Troubleshooting
- How to Use Keytool Command for Importing Certificates
- Installing Provar After Upgrading to macOS Catalina
- Browsers
- Configurations and Permissions
- Connections
- DevOps
- Error Messages
- Provar Manager 3.0 Install Error Resolution
- Provar Manager Test Case Upload Resolution
- 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
- Selenium 4 Upgrade
- Licensing, Installation and Firewalls
- Memory
- Test Builder and Test Cases
- Release Notes