Unable to enter text on canvas element

Hi Team,
I am trying to type text in an editor. I use xpath to click on the editor is //canvas[@id=‘mainCanvas’]

My error log is as below.
2022-09-01 14:40:37.203 DEBUG testcase.Test editor - 16: click(findTestObject(“Object Repository/Page_Document - Document Item 2/canvas_MISSING TEXT_mainCanvas”))
2022-09-01 14:40:37.599 DEBUG testcase.Test editor - 17: delay(3)
2022-09-01 14:40:40.611 DEBUG testcase.Test editor - 18: setText(findTestObject(“Object Repository/Page_Document - Document Item 2/canvas_MISSING TEXT_mainCanvas”), "new text ")
2022-09-01 14:40:42.338 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to set text 'new text ’ of object ‘Object Repository/Page_Document - Document Item 2/canvas_MISSING TEXT_mainCanvas’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to set text 'new text ’ of object ‘Object Repository/Page_Document - Document Item 2/canvas_MISSING TEXT_mainCanvas’
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:979)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$1.call(Unknown Source)
at Test editor.run(Test editor:54)
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:398)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:360)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:255)
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 TempTestCase1662057606049.run(TempTestCase1662057606049.groovy:25)
Caused by: org.openqa.selenium.InvalidElementStateException: invalid element state
(Session info: chrome=104.0.5112.102)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’

My HTML DOM screenshot when text is already added.

Could you pls help me how can I add text?

The HTMl <canvas> element is used to support drawing of graphics and animations. That’s to say, it does not support a value attribute so cannot be used with WebUI.setText().

Hi Russ,
Thanks for the information. Could you please guide me further on how can I add text on canvas?

You can’t. The <canvas> element does not support text input.

The <canvas> element does support the rendering of text as a graphical representation of the characters, but it doesn’t support text input by the user.

If you think it does, then you’re looking at something else, perhaps HTML <input> elements overlayed on the <canvas> element(s).

Hint: You need to learn how your AUT operates before you can write good test code. Then you might avoid barking up the wrong tree.