AppleScript unable to get text from safari

I'm setting a text in a safari textfield with this code :

set myCaseNote to "demo"

tell application "Safari Technology Preview"
    set setData to do JavaScript "document.getElementsByClassName('text-entry')[1].value=" & quoted form of myCaseNote in document 1
end tell

but I want to add a repeat statement to make sure that my text is added before going to the next step.

I though about double check the content of the textfield with this :

 tell application "Safari Technology Preview"
    set DSIDinfoGrab to do JavaScript "document.getElementsByClassName('text-entry')[1].innerHTML;" in current tab of window 1
end tell

Otherwise this don't seems to get anything

Result: ""

Why can I not get the text from the textfield?


Solution 1:

If it's a user input text field, it won't have an innerHTML property (or, it might, but it won't contain any meaningful data) because it's an element that can't contain child HTML elements itself.

You ought to be able to read the value property that you use to set its text content.

document.getElementsByClassName('text-entry')[1].value;