How can I write something to textarea and clear it?

Hi All,

I tried using editContent to write messages to a textarea ( xpath=//*[@id=“editor”]/textarea ) and it fail with error “Target is not contenteditable”.
How can I write messages to a textarea?
Also, does any way to clear the message in the textarea?

Thanks
B.R
Lance

Post url page otherwise it’s impossible to help you

For a normal textarea you should not use need “editContent”, it is for rich text rich text editors.

For a textarea use Type, see here:

{
  "Name": "textarea",
  "CreationDate": "2021-3-12",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "id=iframeResult",
      "Value": ""
    },
    {
      "Command": "sendKeys",
      "Target": "id=w3review",
      "Value": "does not clear"
    },
    {
      "Command": "type",
      "Target": "id=w3review",
      "Value": "clears everything"
      ]
    }
  ]
}

Hi ulrich,

Thanks for your help!
I can use “type” to write messages to the textarea and use “XType” to send out with ${KEY_ENTER}.
But it seems only can type one line to textarea? Is it possible to type multi-lines? (I read messages from csv file, and use
for editContent before)

Thanks!
B.R
Lance

Yes, use \n for this. See also How to create Line breaks in a variable

new line \n

Result:

Hi ulrich,

Thanks for your reply.
\n can work if I put message in Value directly but not in csv file, It show “TEST\nTEST2” if I put this message in csv file.
I will try to find another way for this…

Thanks
B.R
Lance