Troubleshooting: InvalidElementStateException when using setText
Problem
You may encounter the following exception during web test execution:
org.openqa.selenium.InvalidElementStateException:
invalid element state: Element is not currently interactable and may not be manipulated
This usually happens when Selenium/Katalon tries to interact with an element that exists in the DOM but is not ready for interaction.
Common Causes
- The element is not visible yet
- The element is disabled or covered by another element
- The page is still loading or updated dynamically (AJAX)
- The element requires a different interaction approach
Solution 1: Wait Until the Element Is Visible
Before interacting with the element, make sure it is visible and ready.
WebUI.waitForElementVisible(findTestObject(‘your/object’), 30)
WebUI.setText(findTestObject(‘your/object’), ‘Your Value’)
Solution 2: Set the Value Directly Using JavaScript
If the element is visible but still not interactable (for example, due to custom UI controls), you can set the value using JavaScript.
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import org.openqa.selenium.WebElement
import java.util.Arrays
WebElement element = WebUiCommonHelper.findWebElement(
findTestObject(‘your/object’), 30
)
WebUI.executeJavaScript(
“arguments[0].value=‘Your Value’”,
Arrays.asList(element)
)
This approach bypasses standard Selenium actions and directly updates the element.
→ This exception is usually caused by timing or visibility issues. Waiting for the element or using JavaScript when needed can help resolve it effectively.