# How to create test case to write text into Redactor Editor?

**URL:** <https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801>\
**Category:** Miscellaneous\
**Created:** [July 2, 2018, 8:01am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801 "2018-07-02T08:01:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rizky\_Azizi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@Rizky\_Azizi](https://forum.katalon.com/u/Rizky_Azizi)\
**Post date:** [July 2, 2018, 8:01am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/1 "2018-07-02T08:01:00Z")

</div>

Hi,  
We can’t create test case to write inside Redactor editor. Both using recorder and web spy, it will record div\_ as object. Can’t adding setText to the object.  
Any solution? Please help

![](https://s3.amazonaws.com/katalon-forum/editor/is/zn6tsjeka8md.png "Image: https://s3.amazonaws.com/katalon-forum/editor/is/zn6tsjeka8md.png")

[Redactor.png](https://s3.amazonaws.com/katalon-forum/editor/is/zn6tsjeka8md.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 2, 2018, 8:21am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/2 "2018-07-02T08:21:16Z")

</div>

Hello,  
you will probably need something like this:

```auto
driver.executeScript("arguments[0].innerHTML = arguments[1]", element, text);

```

---

<div class="post-metadata">

**Author:** ![Rizky\_Azizi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@Rizky\_Azizi](https://forum.katalon.com/u/Rizky_Azizi)\
**Post date:** [July 2, 2018, 9:18am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/3 "2018-07-02T09:18:25Z")

</div>

Could you please give me an example code for this case in Katalon?

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 2, 2018, 9:39am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/4 "2018-07-02T09:39:49Z")

</div>

i’m writing this from head so errors will occure  
after openBrowser() and navigateTo()

```auto
WebDriver driver = DriverFactory.getWebDriver()
WebElement element = WebUiCommonHelper.findWebElement(objectToWriteTo, 5);
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].innerHTML = arguments[1]", objectToWriteTo, "text writen to div element");

```

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 2, 2018, 10:45am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/5 "2018-07-02T10:45:10Z")

</div>

greeting from TC

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 2, 2018, 10:46am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/6 "2018-07-02T10:46:23Z")

</div>

this is what works on this page:

```auto
//Open browser
WebUI.openBrowser("http://forum.katalon.com/discussion/7659/how-to-create-test-case-to-write-text-into-redactor-editor#latest")

WebUI.scrollToElement(findTestObject('Object Repository/editor'), 3)
WebUI.click(findTestObject('Object Repository/editor'))
WebUI.sendKeys(findTestObject('Object Repository/editor'), "greeting from TC")

```

---

<div class="post-metadata">

**Author:** ![Rizky\_Azizi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@Rizky\_Azizi](https://forum.katalon.com/u/Rizky_Azizi)\
**Post date:** [July 2, 2018, 11:39am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/7 "2018-07-02T11:39:45Z")

</div>

![](https://s3.amazonaws.com/katalon-forum/editor/cg/talhorw4d5oe.png "Image: https://s3.amazonaws.com/katalon-forum/editor/cg/talhorw4d5oe.png")

Hi,  
we still get error after run the test case. Any solution for this?  
Thanks anyway, really appreciate for your help

[err.png](https://s3.amazonaws.com/katalon-forum/editor/cg/talhorw4d5oe.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 2, 2018, 11:52am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/8 "2018-07-02T11:52:14Z")

</div>

add imports

```auto
import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.testng.Assert
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory

```

---

<div class="post-metadata">

**Author:** ![Rizky\_Azizi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@Rizky\_Azizi](https://forum.katalon.com/u/Rizky_Azizi)\
**Post date:** [July 4, 2018, 2:59am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/9 "2018-07-04T02:59:02Z")

</div>

Hello Andrej,  
for ‘Greeting from TC’ test case, do you create Object repository manually? Could you show me object repository for editor?

![](https://s3.amazonaws.com/katalon-forum/editor/ar/4vigzt2g27n2.png "Image: https://s3.amazonaws.com/katalon-forum/editor/ar/4vigzt2g27n2.png")  
We still unable to send keys to the object

Thanks

[sendkey.png](https://s3.amazonaws.com/katalon-forum/editor/ar/4vigzt2g27n2.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 4, 2018, 4:36am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/10 "2018-07-04T04:36:26Z")

</div>

Hello Rizky,  
i defined 2 objects : inner frame and then editor itself  
iframe under name editorIframe:  
 ![](https://s3.amazonaws.com/katalon-forum/editor/ds/nw9xjh9nxsyd.png "Image: https://s3.amazonaws.com/katalon-forum/editor/ds/nw9xjh9nxsyd.png")  
editor as editor:  
 ![](https://s3.amazonaws.com/katalon-forum/editor/w9/m9ej6y6dcwq0.png "Image: https://s3.amazonaws.com/katalon-forum/editor/w9/m9ej6y6dcwq0.png")  
please pay attention to Parent iframe settings

[image.png](https://s3.amazonaws.com/katalon-forum/editor/ds/nw9xjh9nxsyd.png)

[CaptureKat0001.PNG](https://s3.amazonaws.com/katalon-forum/editor/w9/m9ej6y6dcwq0.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 4, 2018, 4:44am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/11 "2018-07-04T04:44:25Z")

</div>

can you send us html of element you are trying to interact with? it’s possible that actions that cover interaction with object are on other level. You need to find object that have defined event listeners to process keyboard inputs. on this page it’s //iframe//body element :  
 ![](https://s3.amazonaws.com/katalon-forum/editor/jr/h46q5ajuuqnb.png "Image: https://s3.amazonaws.com/katalon-forum/editor/jr/h46q5ajuuqnb.png")

[CaptureKat0002.PNG](https://s3.amazonaws.com/katalon-forum/editor/jr/h46q5ajuuqnb.png)

---

<div class="post-metadata">

**Author:** ![Rizky\_Azizi](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@Rizky\_Azizi](https://forum.katalon.com/u/Rizky_Azizi)\
**Post date:** [July 9, 2018, 6:11am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/12 "2018-07-09T06:11:03Z")

</div>

Here is html element from my source.  
We still stuck at this point. Could you help us?

![](https://s3.amazonaws.com/katalon-forum/editor/47/axfcu21p082j.png "Image: https://s3.amazonaws.com/katalon-forum/editor/47/axfcu21p082j.png")

[html2.png](https://s3.amazonaws.com/katalon-forum/editor/47/axfcu21p082j.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 9, 2018, 6:45am UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/13 "2018-07-09T06:45:41Z")

</div>

hello,  
testObject will be defined as //textarea[@id=“Projects\_description”]  
and i’ll go with WebUI.sendKeys(testObject, “text to display”)

---

<div class="post-metadata">

**Author:** ![ddicocco](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ddicocco/32/4757_2.png) [@ddicocco](https://forum.katalon.com/u/ddicocco)\
**Post date:** [August 28, 2024, 9:16pm UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/14 "2024-08-28T21:16:30Z")

</div>

> [@Andrej\_Podhajsky](#):
>
> WebUI.sendKeys(testObject, “text to display”)

wanted to let you know that i used what you gave here as an answer and it worked for me after struggling with rich text field. thank you

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [August 28, 2024, 9:16pm UTC](https://forum.katalon.com/t/how-to-create-test-case-to-write-text-into-redactor-editor/11801/15 "2024-08-28T21:16:30Z")

</div>

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!
