Error "Element_id length is invalid" when trying to SetText with Chrome

Hi Katalon Team
I have problems running a test case on Chrome

The test starts well, setting text correctly into an input field, then validate ok
Then, when trying to set a text into another input field on the next page, Katalon throws exception :

Caused by: org.openqa.selenium.NoSuchElementException: no such element: Element_id length is invalid
At object: 'Object Repository/WEB/inputTest'

Here’s my code, quite simple :

WebUI.openBrowser('xxx')
WebUI.setText(findTestObject('WEB/inputFirst'),  'ok') //works fine
WebUI.click(findTestObject('WEB/buttonNext'))
WebUI.setText(findTestObject('WEB/inputTest'), 'ko') //doesn't work

I have the same problem with Edge, but it’s ok with Firefox

Here is complete error log :

2021-01-14 18:01:22.869 DEBUG testcase.test                  - 7: setText(findTestObject("WEB/inputTest"), "Hello")
2021-01-14 18:01:23.966 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to set text 'Hello' of object 'Object Repository/WEB/inputTest' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to set text 'Hello' of object 'Object Repository/WEB/inputTest'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
	at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:66)
	at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:37)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText(WebUiBuiltInKeywords.groovy:977)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$0.call(Unknown Source)
	at test.run(test:47)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:394)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:385)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:364)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:356)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1610643663403.run(TempTestCase1610643663403.groovy:25)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Element_id length is invalid 

My parameters :

  • Katalon version 7.8.2
  • Chrome version 87.0.4280.141
  • Windows 10

Thanks for your help !

Stevie

Perhaps use:

WebUI.clearText(findTestObject(‘WEB/inputTest’))

before setting your second text. This would standardize what text that is actually in the textbox.

Perhaps you should wait for the element in the next page to be loaded before trying to manipulate it.

Remember that it’s working perfectly fine with Firefox, all of my test cases are running without any issues using Firefox

I only face these problems with Chrome and Edge.
Could it be a problem of drivers versions, or something like that ?

FYI I performed an update of webdrivers using Tools > Update webdrivers

Hi grylion54, Hi kazurayam,
thanks a lot for your replies

I tried both of your proposals, and it still not working
The verifyElementPresent is ok :

01-15-2021 11:18:06 AM verifyElementPresent(findTestObject("WEB/inputTest"), 10)
Elapsed time: 0,479s
Object 'Object Repository/WEB/inputTest' is present

but then I face the same mistake than before when trying to clearText (by the way, there’s no text in that input) :

=============== ROOT CAUSE =====================
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Element_id length is invalid
At object: 'Object Repository/WEB/inputTest'
...
01-15-2021 11:18:06 AM clearText(findTestObject("WEB/inputTest"))
Elapsed time: 1,126s
Unable to clear text of object 'Object Repository/WEB/inputTest' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to clear text of object 'Object Repository/WEB/inputTest' 

I tried to setText without using clearText, and after the verifyElementPresent : still not working :confused:

Thank you for your help !

I’m with @kazurayam

If this really stupid test works, you have a timing problem:

WebUI.click(findTestObject('WEB/buttonNext'))
WebUI.verifyElementPresent(findTestObject('WEB/inputTest'), 10) 

/* ******************************* */
           WebUI.delay(10)
/* ******************************* */

WebUI.setText(findTestObject('WEB/inputTest), 'ko')

In addition, I would use waitForElementVisible instead of verifyElementPresent.

(This is not a bug report - moved to Web Testing)

Hi @Russ_Thomas,
thank you for your reply
Unfortunately, it’s still not working with your proposals, i’m facing the same issues

Have you noticed that the error thrown is “Element_id length is invalid” ? I haven’t found much information with this kind of error. It’s not just a simple “Element not found” exception or something like this, that’s why I’m a bit lost… :sweat:

Yes, I noticed. I did a web search for it and found nothing useful.

For this to proceed and make progress, I would suggest you give me a screenshot that shows the HTML you’re trying to setText on. Make sure you include enough of the HTML so I can see the element’s hierarchy. With that, I can hopefully write a few lines of JavaScript that can make this work.

Here is the source code, the input I’m trying to set text in is highlighted

I think I might know what’s wrong. There are numerous input elements with the same name. If your TestObjects are using those as part of their identity, I suspect that’s why you’re seeing weird issues.

Also, they’re in a form element. When that form is submitted, I have no clue how the server is supposed to make sense of that. But maybe I just don’t know what happens “next” before submit.

Anyway, here’s your JavaScript…

Be sure to continue waiting until the element is visible, then…

String js = 'document.querySelector("#exploi").value = "stevie";'
WebUI.executeJavaScript(js, null)

If for any reason that doesn’t work, let me know what this snippet does. In the browser console, type this:

document.querySelector("#exploi").style.backgroundColor = "pink"

Thank you for sharing the HTML source.

The error message says:

no such element: Element_id length is invalid

On the other hand, in the HTML source I found a line

<input type="button" tabindex="-" class="btn" value="..." style="..." onclick="javascript:fensPopup[fensPopup.length]=openPopup('-----something mysterious hidden----', 440, 600, 'forms[0].xthmexpltc[0]', 'divlexploi');">

I do not see what this javascript does. But I guess, ‘length’ in the javascript may have something to do with the error message “Element_id length is invalid”.

In the HTML source, I found a line:

<script src="chrome-extension://obmgakbogfnpcddcgicnheonogjmbbof/content/wait.js"></script>

I do not see what this extension is. But I guess, this would do something special only on Chrome. So it might have something to do with your issue.


3 Years ago, I encountered an incident where I opened Chrome browser using WebUI.openBrowser() then Katalon Studio opened a bare plain Chrome WITHOUT any custom chrome-extensions installed.

You can make a search this forum with keyword “chrome extension”, then you will find many topics where people had hard time. I do not know any quick answer to this issue.

In your case, your HTML has a line <script src="chrome-extension://obmgakbogf.... but this chrome extension may not available. I am not sure, only you can check it.

1 Like

I can not see which HTML element is selected by these TestObjects ‘WEB/inputFirst’, ‘WEB/buttonNext’, ‘WEB/inputTest’. I need to see the locators (xpath or css selector).

Could you share the screenshot of the definition panel of these TestObjects ?

Hi everybody
sorry for the delay, I was away for a few days
Thanks a lot for all your replies, I will analyse all of these and will get back at you to tell if something solves my problem

Thanks !

Do you have any iframes involved? I faced a similar issue after clicking on a button that triggered a popup, and after closing the popup, I could no longer interact with form fields. I fought this for days until I tried using WebUI.switchToDefaultContent() which solved all my issues. Maybe it can help you to.

Hi Kazurayam,
I looked at this extension, and it seems to be something from Katalon, an extension only visible while running tests
Here is what I can see in chrome://extensions on the chrome window controled by Katalon :


And when I enter the full url of the extension :

So I don’t think this has something to do with my issue
I tried to delete the extension and then run the script again on the same chrome session, and problem was still there

Hi Russ_Thomas,

There are numerous input elements with the same name. If your TestObjects are using those as part of their identity, I suspect that’s why you’re seeing weird issues

I am using the id = exploi, and it seems it’s the only object with this ID. Furthermore, I have no ID problem when using firefox

But I tried these steps and it worked !

String js = ‘document.querySelector(“#exploi”).value = “stevie”;’
WebUI.executeJavaScript(js, null)

if you have any idea…

Thanks again for helping

Hi johnphughesspam,

I indeed have some iframes involved, but I manage them fine, proof is that everything works just fine using firefox. Problems are only with Chrome, that’s what making me crazy

The wait.js extension is, I believe, the smartwait plugin provided by Katalon - safe to ignore.

Bring up the page in the browser, open devtools and put this in the console. Report back with a screenshot of what you see:

document.querySelectorAll("#exploi").length

It should say 1 - anything else is a problem.

It’s anything else (0) so it’s certainly a problem

image