Katalon can't "see" my button inside a Web Component!

What you’ve encountered is the Shadow DOM. This is a standard web practice used for encapsulation, effectively creating a “private” DOM tree inside a web component that is hidden from standard global selectors like document-wide XPath.

I use same architecture when desiging web app. To interact with these elements, you must navigate the Shadow Host first.

The Solution: Shadow Root Interaction

Katalon Studio has built-in support for this, but you must switch your strategy from XPath to CSS Selectors.

  1. Identify the Shadow Host: In your HTML, this is .

  2. Configure the Object:

    • In the Object Repository, open your target element (submit-btn).

    • Set the Selection Method to CSS.

    • Use the selector: #submit-btn.

    • In the Object settings, ensure you define the Shadow Root Parent as the #login-form object.

Custom Keyword: JavaScript Shadow Piercer

If the UI is complex or has multiple nested levels, a JavaScript executor is the most reliable “industry-standard” approach. It allows you to bypass the Selenium search engine and ask the browser directly for the element.

package com.web.components

import com.kms.katalon.core.annotation.Keyword

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import com.kms.katalon.core.webui.driver.DriverFactory

import org.openqa.selenium.JavascriptExecutor

import org.openqa.selenium.WebElement




public class KaabShadowHandler {

    @Keyword

    def clickShadowElement(String hostSelector, String innerSelector) {

        JavascriptExecutor js = (JavascriptExecutor) DriverFactory.getWebDriver()

        // This script traverses the shadowRoot property which XPath cannot see

        String script = "return document.querySelector('${hostSelector}').shadowRoot.querySelector('${innerSelector}')"

        WebElement element = (WebElement) js.executeScript(script)

        

        if (element != null) {

            element.click()

            println "Successfully clicked the shadow element."

        } else {

            WebUI.comment("FAILED: Could not find element inside Shadow Root")

            throw new Exception("Shadow DOM Element not found: ${hostSelector} -> ${innerSelector}")

        }

    }

}

Strategic Advice:

  • XPath is Blind: Remember, XPath cannot cross a shadow boundary. If your HTML contains #shadow-root, you must use CSS or JavaScript.

  • The “Host” is the Key: The host is the “bridge.” You must find the host in the normal DOM before you can dive into the shadow.

  • Check for Nesting: Sometimes developers nest shadow roots inside other shadow roots. If that’s the case, your JavaScript path would need to include multiple .shadowRoot calls.

Is this the only web component in your application, or is the entire dashboard built using this architecture? If is it so , you will need to design framework according to that let me know if you need that i already worked on nextgen apps