# Web elements fail during execution

**URL:** <https://forum.katalon.com/t/web-elements-fail-during-execution/188607>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [February 19, 2026, 11:41am UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607 "2026-02-19T11:41:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevio052002](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/stevio052002/32/33213_2.png) [@stevio052002](https://forum.katalon.com/u/stevio052002)\
**Post date:** [February 19, 2026, 11:41am UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/1 "2026-02-19T11:41:36Z")

</div>

> [@About the Web Testing category](https://forum.katalon.com/t/about-the-web-testing-category/185297/1):
>
> Dear Testers,
> 
> Welcome to the **Web Testing** category, the place for QA professionals and automation enthusiasts to master browser testing with Katalon Studio.
> 
> **Why use this category?**  
> This space helps you learn and share how to design, verify, debug, and execute web test cases efficiently. From simple UI checks to full automation pipelines, it’s where you can grow your skills and exchange ideas.
> 
> **How is it different?**  
> While other categories focus on API, Mobile, or AI testing, this one is dedicated to **web-based applications** , everything that runs in a browser. It covers object strategies, dynamic locators, Selenium compatibility, and self-healing tests.
> 
> **What should topics include?**
> 
> - Questions or solutions related to web test cases
> - Discussions about browser drivers, keywords, and debugging
> - Best practices for web object management or CI/CD setup
> - Tips, code snippets, and real-world web testing examples
> 
> **Do we need this category?**  
> Yes, Web Testing remains one of the most common and foundational testing types in the Katalon ecosystem. Keeping it as a focused category helps new users find answers faster while allowing advanced members to share deeper insights and workflows.
> 
> Happy testing as always,

Web Testing Category

Do you ever face Web elements fail during execution even though they were previously working? Have you faced this Dynamic Elements Not Identified? How to solve and fix this

---

<div class="post-metadata">

**Author:** ![arvind.choudhary](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/arvind.choudhary/32/33165_2.png) [@arvind.choudhary](https://forum.katalon.com/u/arvind.choudhary)\
**Post date:** [February 27, 2026, 10:54am UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/2 "2026-02-27T10:54:59Z")

</div>

> [@stevio052002](#):
>
> Web Testing Category
> 
> Do you ever face Web elements fail during execution even though they were previously working? Have you faced this Dynamic Elements Not Identified? How to solve and fix this

This is a **very common real-world automation problem** — especially in modern web apps (React, Angular, Vue, dynamic DOM refresh, lazy loading, etc.).

Since you’re already experienced in Katalon + automation, I’ll explain this in a **practical, framework-level way** , not basic theory.

* * *

# Why Elements Suddenly Start Failing

Even though they worked earlier, failures usually happen because of:

1. **Dynamic DOM refresh (React/Angular re-render)**

2. **Element ID changing dynamically**

3. **Timing issues (element not ready yet)**

4. **Shadow DOM**

5. **Iframe loading late**

6. **Stale element reference**

7. **AJAX / API-based delayed rendering**

8. **Index-based XPath**

9. **Environment speed differences (local vs CI)**

* * *

# Follow PROVEN FIX STRATEGY (Industry Level Approach)

* * *

## →Never Rely on Auto-Generated XPath

❌ Bad XPath:

```auto
//*[@id="mat-input-123"]

```

❌ Index-based:

```auto
(//button)[3]

```

These WILL break.

* * *

### Instead Use Stable Attributes

✔ Use:

- `data-testid`

- `data-qa`

- `aria-label`

- stable class combinations

- visible text (when stable)

Example:

```auto
//button[normalize-space()='Submit']

```

or

```auto
//*[@data-testid='login-button']

```

If your dev team doesn’t provide stable attributes → ask them to add `data-testid`.

This is industry best practice.

* * *

# → Always Add Explicit Wait (Never Rely on Default Wait)

In Katalon:

```auto
WebUI.waitForElementVisible(findTestObject('Page/Login/btn_Login'), 20)
WebUI.waitForElementClickable(findTestObject('Page/Login/btn_Login'), 20)

```

⚠ Never directly click without wait.

Bad:

```auto
WebUI.click(obj)

```

Good:

```auto
WebUI.waitForElementClickable(obj, 20)
WebUI.click(obj)

```

* * *

# → Handle Dynamic Loading Properly

If page uses AJAX:

Instead of waiting for element directly:

```auto
WebUI.waitForJQueryLoad(20)
WebUI.waitForPageLoad(20)

```

Or custom wait:

```auto
WebUI.waitForElementPresent(obj, 20)

```

* * *

# → Use Smart XPath for Dynamic Text

If dynamic part changes:

Example:

```auto
Order #12345
Order #67890

```

Use:

```auto
//div[contains(text(),'Order #')]

```

or

```auto
//div[starts-with(text(),'Order #')]

```

* * *

# → Handle Stale Element Exception (Very Common in React Apps)

If element re-renders:

Solution → Retry logic

Example:

```auto
int retry = 0
while(retry < 3){
    try{
        WebUI.click(obj)
        break
    } catch(Exception e){
        WebUI.delay(2)
        retry++
    }
}

```

Better → create custom reusable keyword for retry click.

* * *

# → Use Relative XPath (Anchor-Based)

Instead of:

```auto
(//input)[4]

```

Use:

```auto
//label[text()='Email']/following::input[1]

```

This survives DOM structure changes.

* * *

# → If Element Inside iFrame

Always switch:

```auto
WebUI.switchToFrame(findTestObject('iframe_object'), 10)

```

After work:

```auto
WebUI.switchToDefaultContent()

```

* * *

# → Handle Shadow DOM (Very Important)

Katalon default object spy may fail.

Use JavaScript:

```auto
WebUI.executeJavaScript(
"return document.querySelector('custom-element')
.shadowRoot.querySelector('button')", null)

```

* * *

# → Increase Stability Using Smart Wait

Enable:

Project Settings → Execution → WebUI → Smart Wait → Enable

This helps with dynamic rendering.

* * *

# → Debug Smartly

When element fails:

1. Pause execution

2. Open browser dev tools

3. Inspect if:

---

<div class="post-metadata">

**Author:** ![arvind.choudhary](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/arvind.choudhary/32/33165_2.png) [@arvind.choudhary](https://forum.katalon.com/u/arvind.choudhary)\
**Post date:** [February 27, 2026, 11:02am UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/3 "2026-02-27T11:02:08Z")

</div>

# ADVANCED PRO STRATEGY

✔ Create reusable wrapper methods:

Example:

```auto
def safeClick(TestObject obj) {
    WebUI.waitForElementClickable(obj, 20)
    WebUI.scrollToElement(obj, 10)
    WebUI.click(obj)
}

```

✔ Never call WebUI.click directly in test cases

✔ Use centralized custom keywords

✔ Add logging

✔ Add retry

✔ Add screenshots on failure

* * *

# If Dynamic Elements Still Not Identified

Use Dynamic TestObject creation:

```auto
TestObject dynamicObj = new TestObject()
dynamicObj.addProperty("xpath", 
ConditionType.EQUALS, 
"//div[text()='${dynamicValue}']")

```

* * *

# My Suggestion For You

1. Create a reusable WebUI utility class

2. Never depend on Spy-generated locators blindly

3. Enforce locator strategy standards in your project

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [February 27, 2026, 8:07pm UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/4 "2026-02-27T20:07:25Z")

</div>

I think @arvind.choudhary has given you an excellent post on your issue, but I also have one more. If you are doing **regression** testing on your application, you may encounter actual reference changes to elements (maybe because the developers want to implement brand new **javascript** to apply to the piece). In this case, there is nothing you can do except to change your pathway (or identifier). So, you are going to get some “failures” in this case–can I suggest setting your default “FailureHandling” to OPTIONAL and then fixing/investigating the “failures” later.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [February 27, 2026, 10:54pm UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/5 "2026-02-27T22:54:25Z")

</div>

@stevio052002

> [@stevio052002](#):
>
> How to solve and fix this

There is no magical way you can apply easily. You would need to struggle for yourself.

If you want to ask others for help, you need to disclose a lot more information to us. Sharing concrete information will make your problem resolvable for others. You need to disclose sufficient information to be understood by others. Please make efforts to describe your problem with concrete information.

1. I need to see the HTML source of the page. The easiest way for others to see the HTML source is to visit the URL of the problem web page locally using web browser. Tell us the URL. _Here I would assume that your AUT (Application Under Test) is public on the Internet so that anyone has non-restricted access to it. If your AUT is private and hence others can not see it on hands, then nobody would be able to tell you any immediate solution_ . If you can not share the URL, then [save the copy](https://www.howtogeek.com/415086/how-to-save-a-web-page-in-chrome/) the Web Page, as the second best thing, and attach the file to your next post here.
2. I need to know which HTML element you want to grasp. Tell it to us. Take a screenshot manually and mark it to say “I want this element”.
3. I need to see the error log, especially the Java Stack Trace message that tells why a StepFailedException was raised. Do not trim it. Attach the whole log file to your next post here.
4. I need to see how the locator (XPath, CSS Selector, etc) of Test Object is defined. Show it to us. Take a screenshot of the Test Object definition.
5. I need to read the source code of the failing Test Case script. Especially I need to check if your script calls some “waitForElement\*” statements appropriately. Do not trim it. Attach the whole script file to your next post here.

Too much works? — yes, it is much. It is always tiring to make a good question on the net.

Unless you disclose enough information, I can not make any suggestion like “do this, do that”.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [February 27, 2026, 11:26pm UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/6 "2026-02-27T23:26:34Z")

</div>

See also

> [@\[TIP\] How To Help Us Help You!](https://forum.katalon.com/t/tip-how-to-help-us-help-you/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

---

<div class="post-metadata">

**Author:** ![vu.tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/vu.tran/32/20584_2.png) [@vu.tran](https://forum.katalon.com/u/vu.tran)\
**Post date:** [March 2, 2026, 7:07am UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/7 "2026-03-02T07:07:44Z")

</div>

Hi @stevio052002, I saw your question under a category explanation, hence I separated it to bring more attention for our community to support you. It would be great if you could share your problem in details to get faster solutions. Thanks!

---

<div class="post-metadata">

**Author:** ![arvind.choudhary](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/arvind.choudhary/32/33165_2.png) [@arvind.choudhary](https://forum.katalon.com/u/arvind.choudhary)\
**Post date:** [March 2, 2026, 7:39am UTC](https://forum.katalon.com/t/web-elements-fail-during-execution/188607/8 "2026-03-02T07:39:33Z")

</div>

Yes, As he asked the generic question, so answers pouring in are also generic.
