How to Fix Element Not Visible Exception in Katalon Studio
When working with web test automation, you may encounter the following error:
selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted
This exception usually occurs when Katalon (or Selenium under the hood) attempts to interact with a web element before it becomes visible on the page. In this article, we’ll explain why this happens and how to fix it using Katalon’s built-in waiting mechanism.
What Causes Element Not Visible Exception?
This exception typically appears when:
- The page or component is still loading
- The element exists in the DOM but is hidden
- The element appears only after an animation, AJAX call, or user action
- The test script runs faster than the UI can render
Even though the object is correctly identified, Katalon cannot interact with it until it becomes visible to the user.
The Solution: Use Wait For Element Visible
To resolve this issue, you should explicitly wait for the element to become visible before interacting with it.
Katalon provides the Wait For Element Visible keyword for exactly this purpose.
Example Scenario
Let’s say you encounter the error while trying to click a Login button.
Problematic Code
WebUI.openBrowser('http://demoaut.katalon.com')
WebUI.click(findTestObject('btn_Login'))
In this case, the click action may execute before the Login button is fully visible, causing the exception.
Recommended Fix
Add waitForElementVisible before interacting with the element:
WebUI.openBrowser('http://demoaut.katalon.com')
WebUI.waitForElementVisible(findTestObject('btn_Login'), 30)
WebUI.click(findTestObject('btn_Login'))
Why This Works
waitForElementVisiblepauses the test execution- It waits up to 30 seconds for the element to become visible
- Once visible, the click action executes safely
Best Practices to Avoid This Exception
- Always wait for elements that load dynamically
- Use explicit waits instead of relying on delays
- Prefer
waitForElementVisibleoverdelay() - Ensure your Test Object locator is correct and stable
Learn More
To explore this keyword in more detail, check out the official documentation:
[WebUI] Wait For Element Visible
Final Thoughts
The Element Not Visible Exception is not a bug, rather it’s a signal that your test is running faster than the application UI. By adding a simple visibility check, you can make your tests more stable, reliable, and closer to real user behavior.
Happy testing! ![]()
