title: Cannot read properties of null (reading 'ShadowRoot') - Java and Selenium
body: <p>I am trying to web scrape using Java and Selenium but for one part of what I need to web scrape, it requires me to access a shadow DOM element. I am using Javascript executor to access it and I am entering the querySelector snippet needed to retrieve what I am looking for but I am getting a &quot;Cannot read properties of null (reading 'ShadowRoot')&quot; error. Is anyone familiar with this and how to solve it?</p>
  <p>Here is my code snippet:</p>
  <pre><code> String pagePdfUrl = (String) js.executeScript(&quot;document.querySelector('pdf-viewer').shadowRoot.getElementById('content').querySelector('embed').getAttribute('original-url')&quot;);
  </code></pre>
  <p>js is the JavascriptExectuor variable.</p>
  <p>Thank you!</p>