I agree that there are many moving parts here. However breadth-first exploration is rarely a bad thing in problem solving and thus laying out the possible directions (no matter how unlikely they seem) is beneficial. Timings and unlikely events are usually the cause of many problems after all.
That said, @saumil.sah, I’d like to strongly advise you dive into @Russ_Thomas’s way first. Since the API documentation already exposed the necessary commands that can be executed from Javascript, the best way is to just use them.
After that if things don’t work (or it works but it doesn’t abide the level of abstraction you want (executing javascript is kinda like voodoo) then you can explore other directions.
You modified makeTO to use xpath selectors. That’s okay.
You are calling makeTo with a CSS selector. Not okay.
Repeat:
your_xpath means your xpath.
Once again, try to keep the moving targets to a minimum. It takes a while to dig through all your stuff looking for anything that could be wrong. I was just about to give up when I noticed that.
Reminder: the code works as I posted it. If it goes wrong with your modifications, you need to spend time staring at it, line by line, before posting yet-another-error.
WebUI.waitForPageLoad(10)
TestObject tiny = makeTO("#tiny-react_24806645131568596486738_ifr")
WebUI.waitForElementVisible(tiny,10)
String js = '''
var doc = document.querySelector("#tiny-react_24806645131568596486738_ifr").contentDocument;
var p = doc.querySelector("#tinymce p:nth-child(2)");
p.innerHTML = "<b>Hello, World!";
'''
WebUI.executeJavaScript(js, null)
Also, If you want to copy/paste the text to the editor you need to install the plugins. I am using pasteitcleaned for this thing. It handles copy/paste from Word, Excel, PowerPoint, PDF, Websites, Paint, etc. You should try it once.