Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 14, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 14, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 14, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 14, 2025

      I test a lot of AI coding tools, and this stunning new OpenAI release just saved me days of work

      May 14, 2025

      How to use your Android phone as a webcam when your laptop’s default won’t cut it

      May 14, 2025

      The 5 most customizable Linux desktop environments – when you want it your way

      May 14, 2025

      Gen AI use at work saps our motivation even as it boosts productivity, new research shows

      May 14, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025
      Recent

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025

      Perficient’s “What If? So What?” Podcast Wins Gold at the 2025 Hermes Creative Awards

      May 14, 2025

      PIM for Azure Resources

      May 14, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025
      Recent

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025

      You can now share an app/browser window with Copilot Vision to help you with different tasks

      May 14, 2025

      Microsoft will gradually retire SharePoint Alerts over the next two years

      May 14, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to resolve the Null error displayed for shadowRoot element

    How to resolve the Null error displayed for shadowRoot element

    November 5, 2024

    i have written this code in which i am able to get the Shadow element. package org.example; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class Main { public static void main(String[] args) { System.out.println(“Hello and welcome!”); System.setProperty(“webdriver.chrome.driver”, “chromedriver.exe”); WebDriver driver= new ChromeDriver(); driver.get(“https://shop.mercedes-benz.com/en-au/shop/vehicle/srp/demo”); JavascriptExecutor jse = (JavascriptExecutor) driver; WebElement agreeBtn= (WebElement) jse.executeScript(“return document.querySelector(‘cmm-cookie-banner’).shadowRoot.querySelector(‘div’).querySelector(‘div’).querySelector(‘cmm-buttons-wrapper’).querySelector(‘wb7-button:nth-of-type(2) ‘).shadowRoot.querySelector(‘button.button’)”); ((JavascriptExecutor)driver).executeScript(“arguments[0].click();”, agreeBtn); } } the below is the output when i run this program:Nov 05, 2024 10:03:15 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 130, returning the closest version; found: 129; Please update to a Selenium version that supports CDP version 130 Exception in thread “main” org.openqa.selenium.JavascriptException: javascript error: Cannot read properties of null (reading ‘shadowRoot’) (Session info: chrome=130.0.6723.92) Build info: version: ‘4.25.0’, revision: ‘030fcf7918’ System info: os.name: ‘Windows 11’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘17.0.8’ Driver info: org.openqa.selenium.chrome.ChromeDriver Command: [647d6b65e33549f28a4ea4e137e0a4f5, executeScript {script=return document.querySelector(‘cmm-cookie-banner’).shadowRoot.querySelector(‘div’).querySelector(‘div’).querySelector(‘cmm-buttons-wrapper’).querySelector(‘wb7-button:nth-of-type(2) ‘).shadowRoot.querySelector(‘button.button’), args=[]}] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 130.0.6723.92, chrome: {chromedriverVersion: 129.0.6668.9 (ab04602ab643c…, userDataDir: C:UsersusAppDataLocalT…}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:54013}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:54013/devtoo…, se:cdpVersion: 130.0.6723.92, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true} Session ID: 647d6b65e33549f28a4ea4e137e0a4f5 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190) at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545) at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:476) at org.example.Main.main(Main.java:20)

    Process finished with exit code 1 Also, when i check for the dom element into browser, i am able to locate.: PFA the image as well. Can you please advise how can i resolve this? I am really in need to solve this. I will be obliged of your help. Thanks

    enter image description here
    enter image description here
    enter image description here

    Source: Read More

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleFluid Everything Else
    Next Article Global Crackdown Leads to Seizure of Over 22,000 Malicious IPs, Servers

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 15, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4695 – PHPGurukul Cyber Cafe Management System SQL Injection

    May 15, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    A Comprehensive Guide to Creating Editable Templates in Adobe Experience Manager (AEM)

    Development

    The Elder Scrolls 4: Oblivion Remastered leaks with screenshots

    News & Updates

    Everything new in Microsoft Teams from April 2025

    News & Updates

    Researchers from MIT and Harvard University Work on Enhancing AI Integrity: The Urgent Need for Standardized Data Provenance Frameworks

    Development
    Hostinger

    Highlights

    ELEGNT: Expressive and Functional Movement Design for Non-Anthropomorphic Robot

    January 24, 2025

    Nonverbal behaviors such as posture, gestures, and gaze are essential for conveying internal states, both…

    When is Apple Intelligence out for the iPhone 16? Here’s what you need to know

    August 29, 2024

    A Laravel Package to Use the Deepseek API With V3 AI Models

    January 14, 2025

    Integrating KeywordLogger with Test Listeners in Katalon Studio

    June 10, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.