How to get text in textarea for QWebElement?

To obtain the text on a textarea element, you may think about using QWebElement::attribute(“value”) because the text seems to be the value of the textarea element. But actually what is displayed in the textarea is not the value of the “value” attribute of the textarea.

<textarea id="msg" value="bbb" >aaa</textarea>


The content of the textarea is the inner xml of the element. So it seems you can use QWebElement::toInnerXml() to get the text. Yes it is true that you can get the text written in the html file. But you cannot get the user input in the textarea. The return value of this function just keeps the same (in this case,”aaa”) regardlress of what user input in the text box.

To get what user types in the textarea box on the fly, you should use:



where element is the QWebElement object of the textarea.

Posted in

Leave a Reply