18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Need help in using _rteWrite using Java API

lalwaniajaylalwaniajay Members
edited November -1 in Sahi - Open Source
Hi,
I am automating my web page using sahi. There are a few places where i have added rich text editors in iframes.
I can easily set values to the rich text editor when i use the sahi script.

_rteWrite(_rte(0,_in(_div("contents[1]"))), "Hi there");

But i want to use this same functionality using the Java API.
i found browser.rte() API . but i could not find anything similar to rteWrite().

i even tried browser.rite(0,browser.in(browser.div("contents[1]"))).rteWrite("Hi There!");
but doesn't seem to work.
Help in this matter would be highly appreciated.

Comments

  • narayannarayan Administrators
    Hi Ajay,

    Some APIs from the javascript version have been missed out in the Java version. We are fixing that. Mean while, try this

    BrowserElement el = browser.rte(0, browser.in(browser.div("contents[1]")))
    browser.execute("_sahi._rteWrite(" + el + ", 'Hi There!')");

    Regards,
    Narayan
  • Thanks,
    I will work on it and let you know the results.
  • Hi Narayan,
    This seems to be working fine. But when i run this code in a loop with variables, it fails. The script times out.

    Code Used:

    for(some looping code)
    {
    // invoke a dialog
    BrowserElement el = browser.rte(0, browser.in(browser.div("contents[1]")))
    browser.execute("_sahi._rteWrite(" + el + ", '"+variableName+"')");
    // close dialog
    // then do something else.
    // come back to the same page
    }
  • narayannarayan Administrators
    Make sure you escape single quotes in variableName.

    To debug scripts like these, give a hardcoded value to variableName in the loop and check if the loop works correctly. Once you are sure your looping logic is correct, replace with variableName and check.

    Btw, we can get you a new build with rte methods implemented, if you can wait till Friday.

    Regards,
    Narayan
  • Ya sure. I will wait till friday.

    Thanks,
    Ajay
  • Hi Narayan,

    Did the build get released on friday ? I couldnt find any information regarding it on the website.

    Regards,
    Ajay
  • narayannarayan Administrators
    No Ajay, sorry about that. We will get you a private build soon.

    Regards,
    Narayan
  • Thanks Narayan, do let me know when the build is available

    Regards,
    Ajay
  • Hi Narayan,
    I somehow made it work. I think it works better now. Even inside the loop.
    Still waiting for the build though.
    Thanks narayan. This workaround is of great help.

    Regards,
    Ajay
  • narayannarayan Administrators
    Hi Ajay,

    We have emailed you a link to the build.

    Regards,
    Narayan
  • Hi Narayan,
    Thanks for the build.
    Works great.

    Thanks again,
    Ajay
This discussion has been closed.