DOM Inspection Tests Are Not Supported
Where: This release note applies to Lightning Experience and Salesforce Classic.
Why: Parts of Lightning Experience use Lightning web components, which are based on the Web Components standard. This standard includes Shadow DOM, which hides a component's markup, style, and behavior from other components. This encapsulation poses challenges for UI tests, especially tests that rely on globally searching the DOM or reaching into the internals of custom elements.
How: In Spring ’19, we made significant changes to introduce a shadowRoot property that encapsulates an element's DOM subtree. This shadowRoot is represented as a DocumentFragment in the DOM and elements inside this DOM subtree are not available by traditional DOM querying methods. Elements that are rendered by Lightning web components contain this new shadowRoot property.
You can't globally query the DOM for an element inside a shadowRoot. For example, this Selenium WebDriver query throws an error if the <div> tag is inside a custom element with a shadowRoot property.
We recommend writing unit tests for Aura components and Lightning web components.
For Lightning web components, use Jest to write automated tests.