DOM shadow root elements finder using Selenium solution in .NET.
One of the important aspect of web components is encapsulation and Shadow DOM API is a key part of this, allowing hidden DOM trees to be attached to elements in the regular DOM tree. This shadow DOM tree starts with a shadow root, underneath which any elements can be attached, in the same way as the normal DOM. The solution combines the power of Document Query Selector API with Selenium to grab such shadow root DOM trees and interact with any elements encapsulated within it.
Selenium 4.1.x+ - Current supported package/solution version.
Selenium 4.0.x - Check support here.
Selenium 3 - Check support here.
The package is available and can be downloaded using nuget.org package manager.
- Package Name - ShadowRoot.Digger.
- Returns shadow root or nested shadow root from DOM.
- Checks if shadow root or nested shadow root is present or not in the DOM.
NOTE: Supports Selenium 3, 4.0.x & 4.1.x+ versions (Check Selenium Dependency Before Use)
For Selenium 4.0.x - Use versions 2.x.x.
For Selenium 3 - Use versions 1.x.x.
The solution is built on .NetStandard 2.0
- Install the nuget package ShadowRoot.Digger.
- Use below extension methods to get shadow root or nested shadow root.
Required parameters - webdriver instance & shadow root host selector identifier/s.The returned shadow root element from above extension methods can be used to find element/s encapsulated within it.ShadowRootAssist.GetShadowRootElement() ShadowRootAssist.GetNestedShadowRootElement()
NOTE: Use jQuery Selectors or CSS Selectors for shadow root host identifications. - Use below extension methods for checking if shadow root or nested shadow root exists or not.
Required parameters - webdriver instance & shadow root host selector identifier/s.NOTE: Use jQuery Selectors or CSS Selectors for shadow root host identifications.ShadowRootAssist.IsShadowRootElementPresent() ShadowRootAssist.IsNestedShadowRootElementPresent()
Check the solution tests for more information.
NOTE: Google Chrome & shadow DOM in Chrome settings along with ShadowDOM.html have been used for testing the solution.
Google Chrome | Chrome Driver | Microsoft Edge | Edge Driver |
---|---|---|---|
114.0.5735.133 | 114.0.5735.90 | 114.0.1823.43 | 114.0.1823.43 |
113.0.5672.63 | 113.0.5672.63 | 113.0.1774.35 | 113.0.1774.35 |
112.0.5615.165 | 112.0.5615.49 | 112.0.1722.54 | 112.0.1722.54 |
111.0.5563.110 | 111.0.5563.64 | 111.0.1661.54 | 111.0.1661.54 |
110.0.5481.177 | 110.0.5481.77 | 110.0.1587.63 | 110.0.1587.63 |
109.0.5414.119 | 109.0.5414.74 | 109.0.1518.70 | 109.0.1518.70 |
108.0.5359.124 | 108.0.5359.71 | 108.0.1462.54 | 108.0.1462.54 |
107.0.5304.87 | 107.0.5304.62 | 107.0.1418.35 | 107.0.1418.35 |
106.0.5249.119 | 106.0.5249.61 | 106.0.1370.52 | 106.0.1370.52 |
105.0.5195.52 | 105.0.5195.19 | 105.0.1343.53 | 105.0.1343.53 |
104.0.5112.79 | 104.0.5112.79 | 104.0.1293.54 | 104.0.1293.47 |
103.0.5060.114 | 103.0.5060.53 | 103.0.1264.44 | 103.0.1264.45 |
102.0.5005.61 | 102.0.5005.61 | 102.0.1245.33 | 102.0.1245.33 |
101.0.4951.41 | 101.0.4951.41 | 101.0.1210.53 | 101.0.1210.53 |
100.0.4896.75 | 100.0.4896.60 | 100.0.1185.29 | 100.0.1185.29 |
99.0.4844.74 | 99.0.4844.51 | 99.0.1150.46 | 99.0.1150.46 |
98.0.4758.102 | 98.0.4758.102 | 98.0.1108.56 | 98.0.1108.56 |
97.0.4692.71 | 97.0.4692.71 | 97.0.1072.69 | 97.0.1072.69 |
96.0.4664.110 | 96.0.4664.45 | 96.0.1054.62 | 96.0.1054.62 |
95.0.4638.69 | 95.0.4638.54 | 95.0.1020.53 | 95.0.1020.53 |
94.0.4606.81 | 94.0.4606.61 | 94.0.992.23 | 94.0.992.23 |
93.0.4577.82 | 93.0.4577.63 | 93.0.961.27 | 93.0.961.27 |
92.0.4515.131 | 92.0.4515.107 | 92.0.902.45 | 92.0.902.45 |