Hello @Bala_kumar
If you refer to the documentation for this interface method, you will note that -
By default, the text is appended at the current cursor position. The optional replace parameter, which is boolean, can be used to replace the existing content or add to it.
So the behaviour you notice, that is the text is appended to the existing test value when the button is clicked the 2nd time, is expected. Consider using the replace parameter if you wish to overwrite the existing text in the window.
Do let us know if this works for you.