Android Webview Pass Data using HTML Tag

I have a webview inside one of my android fragments.

When I type some text in my android fragment and click a button on a the android fragment, I am able to set an Webview tag’s .value or .innerhtml to that text using Android webView.evaluateJavascript(see below).

And looking at the web view, it I can confirm visually see setting the .value or setting the .innerhtml is working.

However, after these are done, I want to fire some of my webview’s code to read that .value or .innerhtml text and do some operation with it. However, it seems like the web view does not find any data in the .value or .innerhtml.

Does anyone know why it is not updating?

Sample code on android side:

        binding.webview.evaluateJavascript(
            "document.getElementById('test-target').innerHTML='$message';"
             + "document.getElementsByClassName('send-button')[0].click()"
                ){} 

Pseudo code on web view side:

  1. On the send-button onClickListner, I want to read the ‘test-target’.innerhtml and do an operation with it. But it does not find anything, even when I have visually verified that the .innerHTML has been set by the android code from evaluateJavascript().