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

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

Redactor.png

1 Like

Hello,
you will probably need something like this:

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

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

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

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");
1 Like

greeting from TC

this is what works on this page:

//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")

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

err.png

add imports

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

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


We still unable to send keys to the object

Thanks

sendkey.png

Hello Rizky,
i defined 2 objects : inner frame and then editor itself
iframe under name editorIframe:

editor as editor:

please pay attention to Parent iframe settings

image.png

CaptureKat0001.PNG

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 :

CaptureKat0002.PNG

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

html2.png

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