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:

element.evaluateJavaScript("this.value").toString();

 

where element is the QWebElement object of the textarea.

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:
Posted in

Leave a Reply