# Web ID Error - web Element not found?

**URL:** <https://forum.katalon.com/t/web-id-error-web-element-not-found/168851>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [March 20, 2025, 3:17am UTC](https://forum.katalon.com/t/web-id-error-web-element-not-found/168851 "2025-03-20T03:17:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nestadugbartey29](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nestadugbartey29/32/23870_2.png) [@nestadugbartey29](https://forum.katalon.com/u/nestadugbartey29)\
**Post date:** [March 20, 2025, 3:17am UTC](https://forum.katalon.com/t/web-id-error-web-element-not-found/168851/1 "2025-03-20T03:17:16Z")

</div>

I’m running into errors with one page opening in one test, but that same page is not opening in other tests.

I keep getting this error in my failed tests: Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page\_’ located by ‘//a[@id=‘LiverpoolTheme\_wt9\_block\_wtMenu\_DynamicMenuModule\_wt13\_block\_wtMenus\_wt4\_RichWidgets\_wt47\_block\_wtMenuItem\_wt62’]’ not found

I tried to troubleshoot using the Katalon Q&A forum, but my update doesn’t seem to have fixed anything.

---

<div class="post-metadata">

**Author:** ![dineshh](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dineshh/32/24488_2.png) [@dineshh](https://forum.katalon.com/u/dineshh)\
**Post date:** [March 20, 2025, 5:54am UTC](https://forum.katalon.com/t/web-id-error-web-element-not-found/168851/2 "2025-03-20T05:54:58Z")

</div>

To resolve the **WebElementNotFoundException** in Katalon when an element works in one test but fails in others:

## 1. **Fix Locator Issues**

## **Check for Dynamic IDs**

The error `//a[@id='LiverpoolTheme_wt9_block_wtMenu...']` suggests a **dynamic ID** (e.g., auto-generated by frameworks like GWT). These IDs change across sessions, so **avoid using them**. Instead:

- Use a **relative XPath/CSS selector** with stable attributes (e.g., `text`, `class`, `data-testid`):

groovy

```auto
//a[contains(@class, 'menu-item') and text()='Home']

```

- **Re-spy the element** in Katalon Studio to confirm if the ID has changed.
  - Right-click the object → **Update Selected**.

## **Verify Object Repository Path**

Ensure the object’s path in the **Object Repository** matches the current page structure.

- Example:  
❌ Incorrect Path: `Page_OldName`  
✅ Correct Path: `Page_NewName`

## 2. **Handle Timing/Page Load Issues**

Add **explicit waits** to ensure the element is loaded:

groovy

```auto
WebUI.waitForElementPresent(findTestObject('Object Repository/Page/YourElement'), 30)
WebUI.click(findTestObject('Object Repository/Page/YourElement'))

```

## 3. **Check for Context Changes**

If the page opens in a **new tab/iframe** and the context isn’t switched:

- **For new tabs/windows** :

groovy

```auto
WebUI.switchToWindowTitle('Page Title')

```

- **For iframes** :

groovy

```auto
WebUI.switchToFrame(findTestObject('Object Repository/iframe'), 10)
// Perform actions
WebUI.switchToDefaultContent() // Exit iframe

```

## 4. **Debugging Steps**

## **Run in Debug Mode**

Set breakpoints and step through the test to inspect the page state when the error occurs.

## **Capture Screenshots**

Add screenshots before the failure:

groovy

```auto
WebUI.takeScreenshot()

```

## **Check Network/Console**

Add code to log browser console errors:

groovy

```auto
String consoleLog = WebUI.executeJavaScript('return JSON.stringify(console.log)', null)
println "Console Log: $consoleLog"

```

## 5. **Optimize Katalon Settings**

- **Increase Timeout** : Go to **Settings \> WebUI \> Default Timeout** (set to 30+ seconds).
- **Disable Smart Wait** : In some cases, `Settings > WebUI > Enable SmartWait` can conflict with dynamic content.

## 6. **Page URL/Flow Consistency**

Ensure the test navigates to the **correct URL** and follows the same steps:

groovy

```auto
// Navigate explicitly
WebUI.navigateToUrl('https://your-app.com/page')

```

## 7. **Update Dependencies**

- **Upgrade Katalon** to the [latest version](https://docs.katalon.com/katalon-studio/docs/installation-upgrade.html).
- Reinstall or update the **Multi-Level Shadow DOM Plugin** if shadow DOM is involved.

## Example Fix

**Before** (using dynamic ID):

groovy

```auto
WebUI.click(findTestObject('Object Repository/Page_/DynamicIdElement'))

```

**After** (using stable attributes):

groovy

```auto
// Object defined with XPath: //a[contains(text(), 'Submit')]
WebUI.waitForElementPresent(findTestObject('Object Repository/Page_/SubmitButton'), 30)
WebUI.click(findTestObject('Object Repository/Page_/SubmitButton'))

```

---

<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:** [March 20, 2025, 5:42pm UTC](https://forum.katalon.com/t/web-id-error-web-element-not-found/168851/3 "2025-03-20T17:42:35Z")

</div>

As @dineshh says, you should put in a **wait** statement to ensure your object is available to be interacted with. However, I may use:

```auto
WebUI.waitForElementVisible(findTestObject('...'), 10)
WebUI.verifyElementVisible(findTestObject('...'))

WebUI.click(findTestObject('...'))

```

Your script will run **faster** than your network (and therefore your browser) so every so often, you should add these wait\* statements to ensure that both your script and browser are “on the same page”.

And for your **dynamic** variables, you could use the xpath functions: **contains** or **starts-with** to pull apart any `<id>` that are not characters, like:

```auto
xpath = //a[starts-with(@id,'LiverpoolTheme_wt') and contains(@id, 'block_wtMenu_DynamicMenuModule_wt') and contains(@id, 'block_wtMenus_wt') and contains(@id, 'RichWidgets_wt') and contains(@id, 'block_wtMenuItem_wt')]

```

Edit: if you only use the Web Recorder or Web Spy, then this is where you need to spend time to learn how to build these pathways as neither of these tools can do it.

I would also look for other attributes that may be stable, such as **name** or **aria-id**. These only have to be unique for the page.

```auto
xpath = //input[@name = 'YearGroup_StartDate']

```

---

<div class="post-metadata">

**Author:** ![dineshh](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dineshh/32/24488_2.png) [@dineshh](https://forum.katalon.com/u/dineshh)\
**Post date:** [April 3, 2025, 4:55am UTC](https://forum.katalon.com/t/web-id-error-web-element-not-found/168851/4 "2025-04-03T04:55:39Z")

</div>

@nestadugbartey29 Kindly confirm on your resolution
